Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Having trouble writing this program this is what Ive got so far: package kgahan5A; import java.util.Scanner; public class kgahan5A { public static final String While

image text in transcribedHaving trouble writing this program this is what Ive got 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)

;

}

}

The date of the users's 21st birthday should be calculated from the input. Thank you!

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

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: 3

blur-text-image

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

Beginning PostgreSQL On The Cloud Simplifying Database As A Service On Cloud Platforms

Authors: Baji Shaik ,Avinash Vallarapu

1st Edition

1484234464, 978-1484234464

More Books

Students also viewed these Databases questions