
Please Help! I need to create the following program:
Objective of this Program: (1) To learn about having programs decide what to do depending upon the data by using the if...then...else construct and (2) to start using some of the Java API's, by using the String class.
The program is to prompt the user (both computer science and drug dealers refer to their clients as "users") for the date of the month and whether they want the next day or the previous day. E.g., the user would see:
Enter todays date(1-30):
and after responding, the user would see:
Do you want the next or previous day:
The program should output the next day's or previous day's date: e.g, for the input of:
Enter todays date(1-30): 7
Do you want the next or previous day: next
Tomorrow is the 8th.
For the response of 'previous', one would see:
Yesterday was the 6th.
You should also check for erroneous input. Specifically, three possible bad inputs:
(1) the data is not between 1 and 30, inclusive
(2) one is asked the preceding date of the 1st
(3) one is asked the next day of the 30th
If bad input is given, then each of them should have an appropriate message telling of the bad input, e.g.,
Enter todays date(1-30): 36
gets the response:
Please enter a date between 1 and 30.
and the program would terminate. You terminate a program by the statement of System.exit(0);. It should be part of the 'then' clause statement. However, the following input sequence of:
Enter todays date(1-30): 30
Do you want the next or previous day: next
would generate:
There is no date after the 30th.
A simliar response is given for a response of "previous" when the current date is a 1. You do not have to verify whether one correctly types in 'next' or 'previous' correctly. I.e., if the user incorrectly types in the response, you are not responsible for what happens.
And then Extend the program to do the following:
Extend the output to handle the special cases which end in 1, 2, or 3. I.e., 1st, 2nd, 3rd, 21st, 22nd, 23rd. Remember that 11th, 12th, 13th are the correct output.
Verify that the input of 'next' and/or 'previous' is given correctly, and, if incorrect, print out an error statement and terminate the program. However, the response must be case insensitive. I.e., 'Next' or 'NEXT' are acceptable answers.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.