101k views
3 votes
Modify the getFullDate method found in the utility class file named MyUtils.java to determine whether the dateIn String is in USA format or ISO format. The getFullDate method must take the String argument as its parameter and returns a fully descriptive version of the date passed into the method. The method must: a. b. c. d. e. f. a. Include a complete Java header as shown in the Blackboard Resources.

b. Set up a Scanner named key for keyboard input.
c. Prompt the user to input their monthly salary and read that input into a String named inputTxt using nextLine(). If the user enters a valid salary, parse the inputTxt String into a double variable named monthlySalary. If the user doesn’t enter a valid salary input (any non-blank valid positive double), repeat the process using a do-while loop.
d. Create a for loop that cycles the month from 1 to 12 for each 1st day of the month in the year 2023. Create an ISO based date string in the loop (e.g., 2023-01-01, 2023-02-01, etc. – String.format may be useful to do this.) That is the date that the user will deposit 10% of their salary into a saving account bearing 5% annual interest compounded monthly. During each iteration of the loop, the program should print out the fully Split the parameter String into its component parts using substring, indexOf, and possibly other String methods to obtain the numeric forms of the month, day of the month, and year. The String date passed may be in the USA format MM/DD/YYYY or the ISO format YYYY-MM-DD. After determining the String format has been used, store each date item in their own String variables, yearString, monthString, and dayString for example. Your method should still convert each of the String variables created in step a into integer variables, using Integer.parseInt(), to be used in Zeller’s Congruence. Using the appropriate nested if-else structure where necessary for months 1 and 2, determine the day of the week for the date entered using Zeller’s Congruence. Be sure to assign the day of the week to its own integer variable. (Same as previous activity – don’t change it unless there was an error.) Using a switch structure, turn the month number into a String variable that gives the month name in English. (1 will assign the String variable to "January", etc.) (Same as previous activity – don’t change it unless there was an error.) Using a second switch structure, turn the day of the week integer determined in step c into the day of the week in English. (0 will assign the String variable to "Saturday", etc.) Return the fully descriptive date as the result of the method. (Same as previous activity – don’t change it unless there was an error.) Java program in a class named LastnameFirstnameSavings12 with a main method,

1 Answer

5 votes

Final answer:

To modify the getFullDate method, split the parameter string into its component parts to obtain the month, day, and year values. Use Zeller's Congruence to determine the day of the week and convert the month and day of the week to English.

Step-by-step explanation:

To modify the getFullDate method, you will need to first split the parameter string into its component parts to obtain the month, day, and year values. You can use string methods like substring and indexOf to accomplish this.

Once you have the individual date items stored in separate variables, you can convert them to integers using Integer.parseInt() to be used in Zeller’s Congruence.

Next, you can use Zeller's Congruence to determine the day of the week for the given date. Finally, you can use switch structures to convert the month number into the month name in English and the day of the week integer into the day of the week in English. Return the fully descriptive date as the result of the method.

User AvMishra
by
8.4k points