Question: I'm having trouble with this assignment mainly with the calculation of age and syntax, this is what I have so far: package kgahan5A; import java.util.Scanner;

 I'm having trouble with this assignment mainly with the calculation of

I'm having trouble with this assignment mainly with the calculation of age and syntax, this is what I have so far:

package kgahan5A;

import java.util.Scanner;

public class kgahan5A {

public static final String While = null;

public static void main(String[] args) {

//Fetch User input

Scanner scan = new Scanner(System.in);

System.out.print("Enter a name (First,Last):");

String firstLast = scan.nextLine();

System.out.print("Enter " + firstLast + " brith date" + " (MM/DD/YYYY):");

String birthDate = scan.nextLine();

boolean keepGoing = true;

// Fetch user input

boolean condition = false;

do {

int monthInt = -1;

while ((monthInt 12))

;

{

monthInt = 0;

}

do {

boolean keepgoing = true;

if (monthInt == 1)

System.out.println(firstLast + " January " + birthDate);

else if (monthInt == 2)

System.out.println(firstLast + " 21st birthday is/was " + " February " + birthDate);

else if (monthInt == 3)

System.out.println(firstLast + " 21st birthday is/was " + " March " + birthDate);

else if (monthInt == 4)

System.out.println("April");

else if (monthInt == 5)

System.out.println("May");

else if (monthInt == 6)

System.out.println("June");

else if (monthInt == 7)

System.out.println("July");

else if (monthInt == 8)

System.out.println("August");

else if (monthInt == 9)

System.out.println("September");

else if (monthInt == 10)

System.out.println("October");

else if (monthInt == 11)

System.out.println("November");

else if (monthInt == 12)

System.out.println("December");

else if (monthInt == 0)

keepgoing = false;

} while (keepGoing);

} while (condition);

System.out.println(" thank you");

}

{

boolean donothing = false;

while (donothing)

;

}

}

ICS 111: Assignment 5 Using a loop to catch user input errors and get input again Catching and providing user feedback on different/multiple errors Thinking about test cases Assignment Date: Due Date: Late assignment: Not accepted after: Tuesday, February 18 Monday, February 24 (before 11:55pm) 10% penalty Wednesday, February 26 (before 11:55pm) A. Write a program that does the following (note, you can reuse some old code): Computer prints and waits for input: Enter a name (First Last): Enter Mark's birth date (MM/DD/YYYY): Example user input: Mark Zuckerberg 05/14/1984 Computer prints: Mark's 21st birthday is/was on May, 14 2005. Have your program test the date that the user inputs. Specifically, make sure that: The month is between 1-12, inclusive. The day is between 1-31, inclusive. The year is between 1900 and 2020, inclusive. If any of the parts of the date are out of range, or the input is otherwise uninterpretable, print an error message that says "Please enter the birthdate as MM/DD/YYYY" and loop back to get the data again. Keep looping until you get a legal date. Test your program on the following data (enter the dates as shown): James Kirk, 03/22/2233 Kathryn Janeway, 20-May-2331 Kane Tanaka, 01/02/1903 Herman Hollerith, 02/29/1860 Turn in the java file and a screenshot(s) of the program's behavior in the specified inputs. B. Modify the program you wrote in part A so that accepts the common user input error of not using a zero in front of one-digit numbers. Test your program so that it handles the following inputs in additional to ones from part A: Douglas Englebart, 1/30/1925 Marvin Minsky, 8/9/1927 Frances Spence, 3/2/1922 Adele Goldberg, 7/22/1945 Alan Turing, 06/23/1912 The program should still reject input that is out of range by printing "Please enter your birthdate as MM/DD/YYYY" and looping back to get the date again. Hint: Think about using the String method indexOf(). Turn in the java file and a screenshot(s) of the program's behavior in the specified inputs. C. Modify your program you wrote in part B so that it is more specific about the errors. For example, it should have at least three additional error messages, something like: The month must be a number between 1-12. The date must be a number between 1-31. The year must be between 1900-2020. You might have to generate more than one error depending on the user input. Come up with "test cases" that demonstrate the possible errors that a user might make and take a screen shot of how your program handles these tests. Turn in the java file and a screenshot(s) of the program's behavior in the specified inputs. D. (Extra credit, 6 points). Who were/are: Herman Hollerith Alan Turing Douglas Englebart Marvin Minsky Frances Spence Adele Goldberg Search for them, and just write 2-3 sentences about each person

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!