Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hey guys, I need help on some of my CS homework. Below are the instructions The ISO Date standard has been adopted by many software

Hey guys, I need help on some of my CS homework. Below are the instructions

The ISO Date standard has been adopted by many software developers and countries from around the world because its format, YYYY-MM-DD, is directly sortable such that dates are in order.

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. 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.

b. Your method should still convert each of the String variables created in step a into integer variables, using Integer.parseInt(), to be used in Zellers Congruence.

c. 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 Zellers Congruence. Be sure to assign the day of the week to its own integer variable. (Same as previous activity dont change it unless there was an error.)

d. 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 dont change it unless there was an error.)

e. 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.)

f. Return the fully descriptive date as the result of the method. (Same as previous activity dont change it unless there was an error.)

5. Write a Java program in a class named LastnameFirstnameSavings12 with a main method, where Lastname is your actual last name and FirstName is your actual first name. Your program must:

a. Set up a Scanner named key for keyboard input.

b. 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 doesnt enter a valid salary input (any non-blank valid positive double), repeat the process using a do-while loop.

c. Create a for loop that cycles the month from 1 to 12 for each 1 st 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 descriptive month, the amount of the deposit, and the savings balance including accumulated interest as a minimum output. System.printf may be useful in this step

I am confused about how to implement and create the LastnameFirstnameSavings12 class.

Here is what I have so far:

import java.util.Scanner;

public class MyUtils {

public static String getFullDate(String dateIn) {

String[] dateParts;

int month, day, year;

if (dateIn.contains("/")) {

// USA format

dateParts = dateIn.split("/");

month = Integer.parseInt(dateParts[0]);

day = Integer.parseInt(dateParts[1]);

year = Integer.parseInt(dateParts[2]);

} else {

// ISO format

dateParts = dateIn.split("-");

year = Integer.parseInt(dateParts[0]);

month = Integer.parseInt(dateParts[1]);

day = Integer.parseInt(dateParts[2]);

}

if (month == 1 || month == 2) {

month += 12;

year--;

}

int k = year % 100;

int j = year / 100;

int h = (day + 13 * (month + 1) / 5 + k + k / 4 + j / 4 + 5 * j) % 7;

String dayOfWeek = "";

switch (h) {

case 0:

dayOfWeek = "Sunday";

break;

case 1:

dayOfWeek = "Monday";

break;

case 2:

dayOfWeek = "Tuesday";

break;

case 3:

dayOfWeek = "Wednesday";

break;

case 4:

dayOfWeek = "Thursday";

break;

case 5:

dayOfWeek = "Friday";

break;

case 6:

dayOfWeek = "Saturday";

break;

}

String monthString = "";

switch (month) {

case 1:

monthString = "January";

break;

case 2:

monthString = "February";

break;

case 3:

monthString = "March";

break;

case 4:

monthString = "April";

break;

case 5:

monthString = "May";

break;

case 6:

monthString = "June";

break;

case 7:

monthString = "July";

break;

case 8:

monthString = "August";

break;

case 9:

monthString = "September";

break;

case 10:

monthString = "October";

break;

case 11:

monthString = "November";

break;

case 12:

monthString = "December";

break;

}

return dayOfWeek + ", " + monthString + " " + day + ", " + year;

}

}

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_2

Step: 3

blur-text-image_step3

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

MySQL/PHP Database Applications

Authors: Brad Bulger, Jay Greenspan, David Wall

2nd Edition

ISBN: 0764549634, 9780764549632

More Books

Students also viewed these Databases questions

Question

What is an internship?

Answered: 1 week ago

Question

3. Write a policy statement to address these issues.

Answered: 1 week ago

Question

2. Why has the conflict escalated?

Answered: 1 week ago