9/30/21, 7:20 AM Section XXXXXXXXXXCS 1101: Programming and Problem Solving https://learn.zybooks.com/zybook/VANDERBILTCS1101Fall2021/chapter/12/section/16 1/6 Students: This content is controlled by...

Java assignment


9/30/21, 7:20 AM Section 12.16 - CS 1101: Programming and Problem Solving https://learn.zybooks.com/zybook/VANDERBILTCS1101Fall2021/chapter/12/section/16 1/6 Students: This content is controlled by your instructor, and is not zyBooks content. Direct questions or concerns about this content to your instructor. If you have any technical issues with the zyLab submission system, use the Trouble with lab button at the bottom of the lab. 12.16 PA04-B: To Everything There Is A Season (15 pts) Points and submission This exercise is worth 15 points. You have 7 submission attempts, so use them wisely and try to pass all test cases before running out of submissions. Note also that you have to wait for at least one minute before you can submit again. Keep in mind that the score you get from zyLabs tells us how many test cases passed and hence, is not your �nal score for this exercise. The TA will take this into account and will manually look at your submission. The TA will also be looking for incorrect style and other possible deductions before entering your �nal score on codePost. It is possible that you don't get the full points for the exercise even if you passed all the test cases. Goals The overall goals of this exercise is to: Develop programs that utilize multiway and/or nested decisions. More practice with program decomposition. Gain experience testing methods in a step-by-step development process. Problem description You are to write a program called Seasons that prompts the user for a month and day and displays the season in which that date occurs. For reference, we will use the following date cutoffs for the various seasons: Season Dates (inclusive) Winter December 21 – March 19 9/30/21, 7:20 AM Section 12.16 - CS 1101: Programming and Problem Solving https://learn.zybooks.com/zybook/VANDERBILTCS1101Fall2021/chapter/12/section/16 2/6 Season Dates (inclusive) Spring March 20th – June 20th Summer June 21st – September 20th Fall September 21st – December 20th Data Validation For this program, you'll write a speci�c method to perform data validation based on the month and day entered. More speci�cally: 1. Month – the month entered must be a valid month of the year (January – December). 2. Day – the day entered must be a valid day for that month: January, March, May, July, August, October, December have 1-31 days. April, June, September, November have 1-30 days. February has 1-28 days (do not worry about leap years). Sample run 1 Input: aPRIL 11 Run: Enter the month: aPRIL Enter day: 11 This date occurs in the spring. Sample run 2 Input: December 22 Run: 9/30/21, 7:20 AM Section 12.16 - CS 1101: Programming and Problem Solving https://learn.zybooks.com/zybook/VANDERBILTCS1101Fall2021/chapter/12/section/16 3/6 Enter the month: December Enter day: 22 This date occurs in the winter. Sample run 3 enero 15 Run: Enter the month: enero Enter day: 15 Invalid date. Program cannot continue. Sample run 4 Input: June 31 Enter the month: June Enter day: 31 Invalid date. Program cannot continue. Required program decomposition String getMonth(Scanner console) This method is called from the main method and should prompt for the month as a string and return it to the main method. Recall that you must declare the Scanner object in the main method and pass it as a parameter to the method. int getDay(Scanner console) This method is called from main method and should prompt for the day and return it to main. boolean validInput(String inputMonth, int inputDay) 9/30/21, 7:20 AM Section 12.16 - CS 1101: Programming and Problem Solving https://learn.zybooks.com/zybook/VANDERBILTCS1101Fall2021/chapter/12/section/16 4/6 This method is called from main and is passed as parameters the month and day entered by the user. The month value may be a combination of uppercase and lowercase letters. The method should determine whether the month and day entered are valid dates based on ensuring that the month is a valid month and the number of days is a valid number of days for that month. This method returns a boolean true to indicate the month/day are valid and false if either the month or day are invalid. String calcSeason(String inputMonth, int inputDay) This method accepts a valid month and valid day from main and determines in what season the date occurs. The month value may be a combination of uppercase and lowercase letters. This method assumes the month/day value has been veri�ed by the validInput method. Returns a string with one of the following values: "winter", "spring", "summer", "fall". void displaySeason(String season) This method displays the results indicating in what season the date entered by the user occurs. Yes, it will be a very small method with only a print statement. Notes You can use IntelliJ IDEA – if you're ready to use IntelliJ IDEA, you can code use it as your development environment and then copy-and-paste the code to zyBooks for submission. Tips Trim your string input – when working with string input and the nextLine method, it's always a good idea to use the trim method on it. This trims off any leading or trailing blank spaces in the event the user hits the spacebar. It's simple and effective to use. Just add the trim() command onto the end of your the call to nextLine like this: String month = console.nextLine().trim(); Make your checks case insensitive – the user might enter "April" or "april" or "APRIL". Your program should not be sensitive to the issue of case. The way to do this is to use the the equalsIgnoreCase method in your comparisons rather than the equals method. For example, if (inputMonth.equalsIgnoreCase("January")) { Build and test in pieces – think before you code. Write the program in pieces and check each piece after you write it. For example, write a method to read in the month. Then call that method from the main method and print out what gets returned from the method. Once you have that working, move onto a method to get the day. Then a method to validate the month and day. Then the method to determine which season…and so on. Programming style guidelines 9/30/21, 7:20 AM Section 12.16 - CS 1101: Programming and Problem Solving https://learn.zybooks.com/zybook/VANDERBILTCS1101Fall2021/chapter/12/section/16 5/6 Be sure you are following the style guidelines as outlined in the Programming Style Guide document, which can be found on Brightspace under Content | Course Documents. Code with Honor. Copying even two lines of code or providing two lines of code to another student is a violation of the Honor Code. If you're stuck, reach out to your TA's and instructors. 343594.2143690.qx3zqy7 LAB ACTIVITY 12.16.1: PA04-B: To Everything There Is A Season (15 pts) 0 / 25 Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the �rst box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here. Input (from above) Seasons.java (Your program)  Program output displayed here Seasons.java Load default template... import java.util.Scanner; public class Seasons { public static void main(String[] args) { // Type your code here. } } Develop mode Submit mode Run program 1 2 3 4 5 6 7 8 9 9/30/21, 7:20 AM Section 12.16 - CS 1101: Programming and Problem Solving https://learn.zybooks.com/zybook/VANDERBILTCS1101Fall2021/chapter/12/section/16 6/6 Signature of your work History of your effort will appear here once you begin working on this zyLab. What is this? Trouble with lab?
Sep 30, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here