Overview: HW06: CS12Date Due: Tuesday 10/03/23, 11:59pm (39 pts) In this assignment, you will experiment with...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Overview: HW06: CS12Date Due: Tuesday 10/03/23, 11:59pm (39 pts) In this assignment, you will experiment with using the API methods of an existing Java class, CS12Date, as discussed in the lecture materials. This is a simple "teaching" Java class I created, that provides various calendar date capabilities. Use the sample outputs provided on pgs.5-6 to help you along. When you are faced with familiarizing yourself with a "new-to-you" Java class, review its published API, but also experiment with it by doing the following: Create objects of that class type, using its various constructor methods. Do "something" with the objects, by exercising their various API methods. Display the objects before and after, by using their available display methods. Make sure you understand if the objects are behaving as described by their API. Java Objectives: 1) Using existing classes and creating objects [CSLO-2] 2) The CS12Date class and API [CSLO-2] 3) Displaying objects, explicitly using toString() and implicitly [CSLO-2] 4) Experimenting with the methods of a class API [CSLO-3] 5) Perform before-and-after testing using methods of the API [CSLO-4] Problem Summary: Solve a series of date-related problems, one at a time, using the CS12Date class Exercise most of the methods of the CS12Date API, and print the results Perform before-and-after testing using the created objects Preliminaries: First, do the following: a) As always, start by reviewing all the relevant lecture materials first. In particular, make sure to look over the source code examples and code walk-thrus, and the demo video for using CS12Date. b) When it becomes available, please view the Week 6 office hour recording, for a demo of this assignment and setting it up. c) IMPORTANT: download CS12Date.java file into your working directory. It must be present alongside your client program, otherwise you may (WILL) encounter "cannot find symbol" errors. d) In the same directory, create CS12DateClientFL.java, using your template as a starting point. Reverting back to one main() method is fine for this assignment; you don't need multiple methods for each problem, like you did last time. e) Also have the CS12Date API on-hand as a reference for completing this assignment. You'll find this PDF file in the weekly code examples ZIP file. Then, in your CS12DateClientFL.java code, do the following: f) Set up one Scanner object for user inputs. See the example given in the Scanner app note and its sample code. When you need a month, day, or year, the needed code will look something like this: import java.util.Scanner; //this one line appears BEFORE the public class... statement Scanner input = new Scanner(System.in); // done ONCE, inside your main() g) Upfront, declare only (for now) the following "scratch" (reusable) data in your program: 4 CS12Date variables (objects): today, myBday, halloween, christmas; 3 int variables month, day, and year You will reuse these variables/objects to address the various program tasks. Just declare these for now, no need to instantiate them just yet. I prefer to see you instantiate each of these dates problem-by-problem, as the program spec calls for them. h) Use code such as this for EACH month, day, or year to be read for the upcoming steps: System.out.print("Enter month for... > "); month = input.nextInt(); //use existing declared variables for each M/D/Y input Requirements: In your CS12DateClientFL.java code, do each of the following. For each problem: Use the specified constructor form and/or method! Different constructor forms and/or methods are specified for various problems. Make sure all of your outputs are clearly labeled with the problem number Don't cram all outputs together, give yourself some blank space between outputs From here on: please provide overall commenting (narrative) of your program's logic flow. Tell the reader what each problem does, beyond just the simple problem #. Use summary before-comments, NOT end-comments on each and every line! 1) Using the CS12Date default constructor, instantiate a new date object today with its default values (today's date). Print out this date object explicitly using its toString() method with System.out.println(), AND also implicitly, using System.out.println() with just the name of the date object. Both dates should print identically, but implicit (object name only) is simpler and always the way to go. 2) Print today one more time, except this time use its print () method. Use the overloaded print form, and provide it some descriptive labeling message. 3) Using one of the CS12Date month-day-year constructor forms, instantiate a new date object called halloween (note the initial lower case convention), and set its date to that of Halloween this year (October 31st). Print the date using whatever means you wish. 4) Using the CS12Date month-day constructor form, instantiate a new date object called myBday to November 1st of this year. (THIS SHOULD REALLY BE NOV 1", NOT YOUR BIRTHDAY. Yeah, this probably isn't right, but you'll update it later). Print this date using whatever means you wish. DO NOT use your own birthdate in this step, we'll update it later. 5) Using the CS12Date default constructor, instantiate a new default date object called christmas (note the initial lower case convention), then update it from the default date to the date of this coming Christmas using the setDate() method. This represents 2 separate operations. Print the date using whatever means you wish. 6) Advance the step 4 date myBday by 3 days, by using the nextDate() method 3x. Print the new date using whatever means you wish. Then advance the date myBday by one more week, using the laterDate() method, and print the new date using whatever means you wish. 7) Prompt the user for the month, day and year of YOUR birthday this year (3 prompts) using Scanner, as described above in (e) and using the variables declared in (f). Then, using all 3 of the individual mutator (set) methods, and the 3 int vars just read in, update current date of myBday to the date of your birthday this year. Print the date using whatever means you wish. 8) On what date number of the year (1-365 or 1-366) is/was this year's birthday? Use the myBday date and getDateNum() to find the result, then print both your birthday AND this ordinal date together as a one-line String output. For this problem, try and inline the needed expression directly into your print statement! 9) Print both today's date and your birthday from #7, and check whether today is your birthday (if it is, Happy Birthday!). Use either date object (today or myBday) and its equals() method, compare it to the other date using equals(), and print out the T/F verdict. For this problem, try and inline the needed expression directly into your print statement! Since all Java objects are ultimately descended from type Object, use the other CS12Date object for the input parameter Object obj. See the example code in CS12DateUsage.java on Canvas for an example of this if needed. 10) Using the today and myBday dates, compare one date to the other one using the compare() method, using both orderings (see the sample outputs). Print the results. For this problem, try and inline the needed expressions directly into your print statements! Then, also compare today to itself, and print the result. So there should be 3 results in all. The compare() method tells us the relative ordering of two CS12 Date dates: compare() > 0: compare() < 0: compare() = 0: input CS12Date is in future relative to CS12Date object's date input CS12Date is in past relative to CS12Date object's date both CS12Dates are the same See the API for details. You may need to use compare() on a future assignment! 11) Before proceeding, reset the following individual integer variables: month=0, day=0, year=0. Reset the 3 local int variables only, not by using the 3 mutator methods. Then, using the 3 individual accessor (get) methods, reprint the date of this year's birthday in myBday, except print it in "dashes" form, MM-DD-YYYY. You will need to use string concatenation. Can you inline the needed 3 expressions directly into the print statement?? Print the new date as a String using println(). Note that you aren't "altering" the original myBday, you are just taking it apart using the accessors, and "reassembling" it to create a new String, which you will then print using System.out.println(). Sample output: Your resulting outputs should pretty closely resemble these, except for YOUR birthday info (you can label the outputs however you wish). Make sure you are using the specified constructor forms or methods, and put some blank space between problems for readability! --JGRASP exec: java CS12DateClientRL la) today explicitly using tostring() - 9/9/2023 1b) today implicitly using just object name - 9/9/2023 ......... 2) This is default constructor date of today www year: month: day: text: toString(): day in year: leap year? year: month: day: text: 3) Halloween using -d-y constructor specifically toString(): day in year: leap year? year: month: 2023 9 9 day: text: toString(): day in year: leap year? ====== 9/9/2023 252 false 2023 10 31 >Your today date will differ 4) Imaginery birthday using m-d constructor specifically 10/31/2023 304 false 2023 11 1 11/1/2023 305 false YES, use this specific date and NOT your own birthday! ******* 5) Christmas using default constructor THEN setDate(): 12/25/2023 6a) 3 days past so-called birthday using nextDate(): 11/4/2023 6b) 1 week past so-called birthday using laterDate(): 11/11/2023 This year's birthday month? > 7 This year's birthday day? > 18 This year's birthday year?> 2023 7) This year's birthday using mutators is/was: =========== ====== year: month: day: text: toString(): day in year: leap year? 2023 7 18 This should be YOUR birthdate this year, not mine 7/18/2023 199 false Updated myBday, using above inputs 8) This year's birthday 7/18/2023 is was day #: 199 9) Is today 9/9/2023 my birthday 7/18/2023? false 10a) compare today to my birthday: -1 10b) compare my birthday to today: 1 10c) compare today to today: 0 11) This year's birthday with dashes is still: 7-18-2023 ----GRASP: operation complete. Common things to check before code review or submitting: Put a blank line between each problem, don't crowd the outputs together Use the specified constructor of method forms cited, follow the program spec CLOSELY! Every date setup should NOT use a full constructor, for example o There are TWO ways to advance the date needed in #6 Do NOT hardwire your own birthday or birthdate into the code!! After you do enter your own birthday in #7, update myBday with those 3 inputs Use specified methods to do this Comment your code problem by problem Before-comments preferred over end-comments for program logic Declare ALL vars and objects upfront, not as the need for them arises In general, follow the program spec, sample outputs, and rubric closely! Make use of the code review option if possible, for max points o Or have Bowyn look your code over during his hours Overview: HW06: CS12Date Due: Tuesday 10/03/23, 11:59pm (39 pts) In this assignment, you will experiment with using the API methods of an existing Java class, CS12Date, as discussed in the lecture materials. This is a simple "teaching" Java class I created, that provides various calendar date capabilities. Use the sample outputs provided on pgs.5-6 to help you along. When you are faced with familiarizing yourself with a "new-to-you" Java class, review its published API, but also experiment with it by doing the following: Create objects of that class type, using its various constructor methods. Do "something" with the objects, by exercising their various API methods. Display the objects before and after, by using their available display methods. Make sure you understand if the objects are behaving as described by their API. Java Objectives: 1) Using existing classes and creating objects [CSLO-2] 2) The CS12Date class and API [CSLO-2] 3) Displaying objects, explicitly using toString() and implicitly [CSLO-2] 4) Experimenting with the methods of a class API [CSLO-3] 5) Perform before-and-after testing using methods of the API [CSLO-4] Problem Summary: Solve a series of date-related problems, one at a time, using the CS12Date class Exercise most of the methods of the CS12Date API, and print the results Perform before-and-after testing using the created objects Preliminaries: First, do the following: a) As always, start by reviewing all the relevant lecture materials first. In particular, make sure to look over the source code examples and code walk-thrus, and the demo video for using CS12Date. b) When it becomes available, please view the Week 6 office hour recording, for a demo of this assignment and setting it up. c) IMPORTANT: download CS12Date.java file into your working directory. It must be present alongside your client program, otherwise you may (WILL) encounter "cannot find symbol" errors. d) In the same directory, create CS12DateClientFL.java, using your template as a starting point. Reverting back to one main() method is fine for this assignment; you don't need multiple methods for each problem, like you did last time. e) Also have the CS12Date API on-hand as a reference for completing this assignment. You'll find this PDF file in the weekly code examples ZIP file. Then, in your CS12DateClientFL.java code, do the following: f) Set up one Scanner object for user inputs. See the example given in the Scanner app note and its sample code. When you need a month, day, or year, the needed code will look something like this: import java.util.Scanner; //this one line appears BEFORE the public class... statement Scanner input = new Scanner(System.in); // done ONCE, inside your main() g) Upfront, declare only (for now) the following "scratch" (reusable) data in your program: 4 CS12Date variables (objects): today, myBday, halloween, christmas; 3 int variables month, day, and year You will reuse these variables/objects to address the various program tasks. Just declare these for now, no need to instantiate them just yet. I prefer to see you instantiate each of these dates problem-by-problem, as the program spec calls for them. h) Use code such as this for EACH month, day, or year to be read for the upcoming steps: System.out.print("Enter month for... > "); month = input.nextInt(); //use existing declared variables for each M/D/Y input Requirements: In your CS12DateClientFL.java code, do each of the following. For each problem: Use the specified constructor form and/or method! Different constructor forms and/or methods are specified for various problems. Make sure all of your outputs are clearly labeled with the problem number Don't cram all outputs together, give yourself some blank space between outputs From here on: please provide overall commenting (narrative) of your program's logic flow. Tell the reader what each problem does, beyond just the simple problem #. Use summary before-comments, NOT end-comments on each and every line! 1) Using the CS12Date default constructor, instantiate a new date object today with its default values (today's date). Print out this date object explicitly using its toString() method with System.out.println(), AND also implicitly, using System.out.println() with just the name of the date object. Both dates should print identically, but implicit (object name only) is simpler and always the way to go. 2) Print today one more time, except this time use its print () method. Use the overloaded print form, and provide it some descriptive labeling message. 3) Using one of the CS12Date month-day-year constructor forms, instantiate a new date object called halloween (note the initial lower case convention), and set its date to that of Halloween this year (October 31st). Print the date using whatever means you wish. 4) Using the CS12Date month-day constructor form, instantiate a new date object called myBday to November 1st of this year. (THIS SHOULD REALLY BE NOV 1", NOT YOUR BIRTHDAY. Yeah, this probably isn't right, but you'll update it later). Print this date using whatever means you wish. DO NOT use your own birthdate in this step, we'll update it later. 5) Using the CS12Date default constructor, instantiate a new default date object called christmas (note the initial lower case convention), then update it from the default date to the date of this coming Christmas using the setDate() method. This represents 2 separate operations. Print the date using whatever means you wish. 6) Advance the step 4 date myBday by 3 days, by using the nextDate() method 3x. Print the new date using whatever means you wish. Then advance the date myBday by one more week, using the laterDate() method, and print the new date using whatever means you wish. 7) Prompt the user for the month, day and year of YOUR birthday this year (3 prompts) using Scanner, as described above in (e) and using the variables declared in (f). Then, using all 3 of the individual mutator (set) methods, and the 3 int vars just read in, update current date of myBday to the date of your birthday this year. Print the date using whatever means you wish. 8) On what date number of the year (1-365 or 1-366) is/was this year's birthday? Use the myBday date and getDateNum() to find the result, then print both your birthday AND this ordinal date together as a one-line String output. For this problem, try and inline the needed expression directly into your print statement! 9) Print both today's date and your birthday from #7, and check whether today is your birthday (if it is, Happy Birthday!). Use either date object (today or myBday) and its equals() method, compare it to the other date using equals(), and print out the T/F verdict. For this problem, try and inline the needed expression directly into your print statement! Since all Java objects are ultimately descended from type Object, use the other CS12Date object for the input parameter Object obj. See the example code in CS12DateUsage.java on Canvas for an example of this if needed. 10) Using the today and myBday dates, compare one date to the other one using the compare() method, using both orderings (see the sample outputs). Print the results. For this problem, try and inline the needed expressions directly into your print statements! Then, also compare today to itself, and print the result. So there should be 3 results in all. The compare() method tells us the relative ordering of two CS12 Date dates: compare() > 0: compare() < 0: compare() = 0: input CS12Date is in future relative to CS12Date object's date input CS12Date is in past relative to CS12Date object's date both CS12Dates are the same See the API for details. You may need to use compare() on a future assignment! 11) Before proceeding, reset the following individual integer variables: month=0, day=0, year=0. Reset the 3 local int variables only, not by using the 3 mutator methods. Then, using the 3 individual accessor (get) methods, reprint the date of this year's birthday in myBday, except print it in "dashes" form, MM-DD-YYYY. You will need to use string concatenation. Can you inline the needed 3 expressions directly into the print statement?? Print the new date as a String using println(). Note that you aren't "altering" the original myBday, you are just taking it apart using the accessors, and "reassembling" it to create a new String, which you will then print using System.out.println(). Sample output: Your resulting outputs should pretty closely resemble these, except for YOUR birthday info (you can label the outputs however you wish). Make sure you are using the specified constructor forms or methods, and put some blank space between problems for readability! --JGRASP exec: java CS12DateClientRL la) today explicitly using tostring() - 9/9/2023 1b) today implicitly using just object name - 9/9/2023 ......... 2) This is default constructor date of today www year: month: day: text: toString(): day in year: leap year? year: month: day: text: 3) Halloween using -d-y constructor specifically toString(): day in year: leap year? year: month: 2023 9 9 day: text: toString(): day in year: leap year? ====== 9/9/2023 252 false 2023 10 31 >Your today date will differ 4) Imaginery birthday using m-d constructor specifically 10/31/2023 304 false 2023 11 1 11/1/2023 305 false YES, use this specific date and NOT your own birthday! ******* 5) Christmas using default constructor THEN setDate(): 12/25/2023 6a) 3 days past so-called birthday using nextDate(): 11/4/2023 6b) 1 week past so-called birthday using laterDate(): 11/11/2023 This year's birthday month? > 7 This year's birthday day? > 18 This year's birthday year?> 2023 7) This year's birthday using mutators is/was: =========== ====== year: month: day: text: toString(): day in year: leap year? 2023 7 18 This should be YOUR birthdate this year, not mine 7/18/2023 199 false Updated myBday, using above inputs 8) This year's birthday 7/18/2023 is was day #: 199 9) Is today 9/9/2023 my birthday 7/18/2023? false 10a) compare today to my birthday: -1 10b) compare my birthday to today: 1 10c) compare today to today: 0 11) This year's birthday with dashes is still: 7-18-2023 ----GRASP: operation complete. Common things to check before code review or submitting: Put a blank line between each problem, don't crowd the outputs together Use the specified constructor of method forms cited, follow the program spec CLOSELY! Every date setup should NOT use a full constructor, for example o There are TWO ways to advance the date needed in #6 Do NOT hardwire your own birthday or birthdate into the code!! After you do enter your own birthday in #7, update myBday with those 3 inputs Use specified methods to do this Comment your code problem by problem Before-comments preferred over end-comments for program logic Declare ALL vars and objects upfront, not as the need for them arises In general, follow the program spec, sample outputs, and rubric closely! Make use of the code review option if possible, for max points o Or have Bowyn look your code over during his hours
Expert Answer:
Answer rating: 100% (QA)
Solutions Step 1 Here is the code for the given task it includes all the problems given Make sure to integrate this code into your CS12DateClientFLjava file import javautilScannerpublic class CS12DateClientFL public static void mainString args Step f Set up Scanner object for user inputs Scanner input new ScannerSystemin Step g Declare variables CS12Date ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
2020 was a very unusual year for government spending because of the COVID response. The nonpartisan Congressional Budget Office provides a breakdown of money that was brought in from taxes and spent...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
List three specific parts of the Case Guide, Objectives and Strategy Section (See below) that you had the most difficulty understanding. Describe your current understanding of these parts. Provide...
-
M DO NOT TURN THIS PAGE UNTIL YOU ARE TOLD TO DO SO SECTION B. ANSWER ANY THREE (3) QUESTIONS Question 1 (25 marks) You have analyzed Solar Power Ltd. and have reported the results of your analysis...
-
Identify the features common to the gift tax formula and the estate tax formula.
-
The probability that a certain kind of flower seed will germinate is .80. (a) If 200 seeds are planted, what is the probability that fewer than 150 will germinate? (b) That at least 150 will...
-
Bank Reconciliation} Tiny Corp. prepares monthly bank reconciliations of its chequing account balance. The bank statement for October 2018 indicated the following: An analysis of cancelled cheques...
-
Clarissa McWhirter, vice-president of Cyprus Company, was pleased to see a small variance on the income statement after the trouble the company had been having in controlling manufacturing costs. She...
-
(1 point) A particle traveling in a straight line is located at point (4, 5, 1) and has speed 8 at time t = 0. The particle moves toward the point (6, 7, 5) with constant acceleration (2, 12, 4) ....
-
Question 5 [ 4 points ] In the table shown below is accounting equation information as it applies to Second Time Around Clothing. Calculate the missing amounts assuming that a . Assets decreased by $...
-
Assume y-4-8(x-3) is tangent to the graph of g(a). Based on this information, what is g(3)?
-
What are the different ways to approach development in economics? What is the importance of the HDI (The Human Development Index) to implement a series of actions regarding development? 2. about the...
-
Have cultural issues become more prominent in recent years (in a Global context as well as Canada specifically)? What forces stand in the way of achieving greater equity and diversity? How does...
-
Suppose a company is choosing between bank loans and bonds. The CEO has no Finance background and she is surprised to learn that while the interest rate in the bank loan is significantly lower, the...
-
How does the genotype-phenotype map vary across different biological systems, and what are the underlying genetic and epigenetic mechanisms that contribute to the generation and modulation of...
-
Identify the intercepts. 2 -4 2 Select the correct choice below and, if necessary, fill in the answer box to complete your choice A. The y-intercept(s) is/are (0,-5) (Type an ordered pair. Use a...
-
You are planning to purchase your first home five years from today. The required down payment will be $50,000. You currently have $20,000. but you plan to contribute $500 each quarter to a special...
-
Liz Hicks Accounting Ltd.s (LHA) policy is to report all cash flows arising from interest and dividends in the operating section. LHA owns a 30% interest in an associated company, LH Bookkeeping Inc....
-
Identify whether IAS 40 applies to the following items. In other words, are they investment properties? While there is some amount of judgment depending on the circumstances, consider the most...
-
Jamie Bleay Law Ltd.s policy is to report all cash inflows from interest and dividends in the investing section and cash outflows arising from interest and dividends in the financing section. Jamie...
-
Preparation of Adjusting Entries} Osaga Beach Resort operates a resort complex that specializes in hosting small business and professional meetings. Osaga Beach closes its fiscal year on January 31,...
-
Revenue Recognition and Matching} Aunt Bea's Catering Service provides catering service for special occasions. During 2018, Aunt Bea performed \(\$ 128,300\) of catering services and collected \(\$...
-
Effects of Adjusting Entries on the Basic Accounting Equation} Four adjusting entries are shown below: Required: CONCEPTUAL CONNECTION Analyze the adjusting entries and identify their effects on the...
Study smarter with the SolutionInn App