Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions: 1. Create a new Blue project, Project1, with a class, Dater 2. In main(), prompt the user to enter the day, month and year

image text in transcribed
image text in transcribed
image text in transcribed
Instructions: 1. Create a new Blue project, Project1, with a class, Dater 2. In main(), prompt the user to enter the day, month and year with a space in between 1. The entries will be numeric, but not necessarily legal (e.g., month 13) 3. Check the year, month and day, in that order: 1. If the year is valid (between 0-2099 inclusive), perform step 3.2, otherwise print an error and exit the program. 2. If the year is valid, check the month. If the month is between 1-12, perform step 3.3, otherwise print an error and exit the program 3. If the month is valid, check the day. If valid decrement it by 1. This may cause ramifications. If so, adjust month and/or year, as appropriate. Then print the decremented day, with the month spelled out as shown below, otherwise print an error and exit the program. Requirements and Observations: 1. Just use if, if-else, if-else if, and switch statements. If we didn't talk about it in class, or it didn't show up in assigned ZyBooks readings, don't use it. System.exit(), return, arrays, etc., are all verboten. 2. Think about this problem before you code. Figure out the algorithm first, trying it with multiple dates. If you can't do this by hand, you can't cajole Java into solving it for you. 3. Structure the program to make it easy to understand, with nested ifs, switch statements where appropriate, and additional variables if needed. 4. Put comments besides the beginning an if statement to make it clear what that is doing, e.g. // leap year 5. The description in the instructions is outlining a set of if-else-if statements (otherwise == else) 6. Your instructor found that writing boolean variables -- isLeap Year, is 30DayMonth, and is31 Day Month -- helped keep the logic easier to understand. 7. The program will be tested with tricky edge cases, but we will not worry about Gregorian v. Julian calendars. Remember that a year is a leap year if it is divisible by 4 and not divisible by 100 (e.g. 2020) or if it is divisible by 400. In a leap year, February has 29 days; otherwise it has 28. 8. Prompts should look exactly like those shown in the sample output. 9. Your project must compile to get at least partial credit. Sample Output (user input is in bold): Date (month day year): 2 28 2021 February 27, 2021 Date (month day year 21 2021 January 31, 2021 Date (month day year 11 2021 December 31, 2020 Date (month day year), 131 2021 Invalid month Date (month day year): 12 32 2021 Invalid day Date (month day year) 2 29 2020 February 28, 2020 Date (month day year): 2 29 2019 Invalid day Date (month day year): 11 2100 Invalid year Date (month day year): 110 December 31, 1 Date (month day year: 5 19 1900 May 18, 1900 Date (month day year): 7 7 1802 July 6, 1802 Use the 11 dates shown here for your screenshot Deliverables: 1. The project, zipped 2. A screenshot, showing the output of your program. Use the values shown in the Sample output. The screenshot should be uploaded separately from your project, and not zipped just jpg or png 3 The README.TXT with these fields: 1. PROJECT TITLE: 2. PURPOSE OF PROJECT 3. VERSION or DATE: AUTHOR 5. PROJECT STATUS: (a brief commentary on how you think the project stands, relative to the requirements, eg, working perfectly, has trouble with February, doesn't even compile 6. PROJECT CHALLENGES: [What was easy about this project? What was hard? What did you think about this project? Turn off Clear screen at method cal so you can show more output on one screen. If your program crashes or shows incorrect output, just move on to the next case Om Clear Copy Month day year) D Code CM NW Checklist (not to hand in): Auto-layout applied? (command-shift-I or ctrl-shift-1) Comment block filled in? (Name, Date, Description) Appropriate comments included in the body of your code? README filled in? Descriptive identifier names chosen? (a, c, se, and st will get a 0 for sure) Redundant parentheses removed? -- e.g., a = (b*c) + (d*e); or worse a = ((b*c) + (d*e)); Both should be written a = b*c + d'e; Spelling/spacing checked? Your output must match mine. Appropriate blank lines in the code to aid legibility? (e.g., 1 blank line separating input, processing and output) sections) Defined variables for any calculation? Uploaded project? Uploaded separate screenshot of output? Read this checklist? Instructions: 1. Create a new Blue project, Project1, with a class, Dater 2. In main(), prompt the user to enter the day, month and year with a space in between 1. The entries will be numeric, but not necessarily legal (e.g., month 13) 3. Check the year, month and day, in that order: 1. If the year is valid (between 0-2099 inclusive), perform step 3.2, otherwise print an error and exit the program. 2. If the year is valid, check the month. If the month is between 1-12, perform step 3.3, otherwise print an error and exit the program 3. If the month is valid, check the day. If valid decrement it by 1. This may cause ramifications. If so, adjust month and/or year, as appropriate. Then print the decremented day, with the month spelled out as shown below, otherwise print an error and exit the program. Requirements and Observations: 1. Just use if, if-else, if-else if, and switch statements. If we didn't talk about it in class, or it didn't show up in assigned ZyBooks readings, don't use it. System.exit(), return, arrays, etc., are all verboten. 2. Think about this problem before you code. Figure out the algorithm first, trying it with multiple dates. If you can't do this by hand, you can't cajole Java into solving it for you. 3. Structure the program to make it easy to understand, with nested ifs, switch statements where appropriate, and additional variables if needed. 4. Put comments besides the beginning an if statement to make it clear what that is doing, e.g. // leap year 5. The description in the instructions is outlining a set of if-else-if statements (otherwise == else) 6. Your instructor found that writing boolean variables -- isLeap Year, is 30DayMonth, and is31 Day Month -- helped keep the logic easier to understand. 7. The program will be tested with tricky edge cases, but we will not worry about Gregorian v. Julian calendars. Remember that a year is a leap year if it is divisible by 4 and not divisible by 100 (e.g. 2020) or if it is divisible by 400. In a leap year, February has 29 days; otherwise it has 28. 8. Prompts should look exactly like those shown in the sample output. 9. Your project must compile to get at least partial credit. Sample Output (user input is in bold): Date (month day year): 2 28 2021 February 27, 2021 Date (month day year 21 2021 January 31, 2021 Date (month day year 11 2021 December 31, 2020 Date (month day year), 131 2021 Invalid month Date (month day year): 12 32 2021 Invalid day Date (month day year) 2 29 2020 February 28, 2020 Date (month day year): 2 29 2019 Invalid day Date (month day year): 11 2100 Invalid year Date (month day year): 110 December 31, 1 Date (month day year: 5 19 1900 May 18, 1900 Date (month day year): 7 7 1802 July 6, 1802 Use the 11 dates shown here for your screenshot Deliverables: 1. The project, zipped 2. A screenshot, showing the output of your program. Use the values shown in the Sample output. The screenshot should be uploaded separately from your project, and not zipped just jpg or png 3 The README.TXT with these fields: 1. PROJECT TITLE: 2. PURPOSE OF PROJECT 3. VERSION or DATE: AUTHOR 5. PROJECT STATUS: (a brief commentary on how you think the project stands, relative to the requirements, eg, working perfectly, has trouble with February, doesn't even compile 6. PROJECT CHALLENGES: [What was easy about this project? What was hard? What did you think about this project? Turn off Clear screen at method cal so you can show more output on one screen. If your program crashes or shows incorrect output, just move on to the next case Om Clear Copy Month day year) D Code CM NW Checklist (not to hand in): Auto-layout applied? (command-shift-I or ctrl-shift-1) Comment block filled in? (Name, Date, Description) Appropriate comments included in the body of your code? README filled in? Descriptive identifier names chosen? (a, c, se, and st will get a 0 for sure) Redundant parentheses removed? -- e.g., a = (b*c) + (d*e); or worse a = ((b*c) + (d*e)); Both should be written a = b*c + d'e; Spelling/spacing checked? Your output must match mine. Appropriate blank lines in the code to aid legibility? (e.g., 1 blank line separating input, processing and output) sections) Defined variables for any calculation? Uploaded project? Uploaded separate screenshot of output? Read this checklist

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Master The Art Of Data Storytelling With Visualizations

Authors: Alexander N Donovan

1st Edition

B0CNMD9QRD, 979-8867864248

More Books

Students also viewed these Databases questions

Question

7. What will learners do with language after they have left us?

Answered: 1 week ago