Question: program in Java Homework 4-1 Write a program that computes the fare on the Copenhagen Transit system given two inputs from the user The zone


Homework 4-1 Write a program that computes the fare on the Copenhagen Transit system given two inputs from the user The zone number. The passenger type Your prompts to the user must be Enter zone number : Enter adult or child : The fare on Copenhagen Transit is specified as follows: If the zone is 2 or smaller and the ticket type is "adult," the fare is 23.0. If the zone is 2 or smaller and the ticket type is "child," the fare is 11.5. If the zone is 3 and the ticket type is "adult," the fare is 34.5. If the zone is 3 or 4 and the ticket type is "child," the fare is 23.0 If the zone is 4 and the ticket type is "adult," the fare is 46 0. If the zone is greater than 4, the fare is -1.00 (since your calculator does not handle inputs that high). Your output must be of the format: The fare for aduitorchild to zone number zoneNumber is faxe. Please note that your class should be named Copenhagen Transit Homework 4-2 Write a program that asks the user for their age in days. The program will compute the person's age in years (you can assume that all years have 365 days) and then prints one of the following messages 1. If the user is 1 year old or younger, print: "You are an infant" 2. If the user is over 1 year old and 3 years old or younger, print: "You are a toddler" 3. If the user is over 3 years old and 12 years old or younger, print "You are a child" 4. If the user is over 12 years old and 19 years old or younger, print "You are a teenager" 5. If the user is over 19 years old and 21 years old or younger, print: "You are a young adult" 6. If the user is over 21 years old and 50 years old or younger, print: "You are an adult" 7. If the user is over 50 years old but 65 years old or younger, print "You are middle aged" 8. If the user is over 65 years, print: "You are a senior citizen" For example: If the user entered: 350, your program would output: You are an infant If the user entered: 800, your program would output: You are a toddler It the user entered, 1825, your program would output: You are a child If the user entered, 5475, your program would output: You are a teenager If the user entered, 7300, your program would output: You are a young adult If the user entered, 10950, your program would output: You are an adult If the user entered, 23725, your program would output: You are middle aged If the user entered, 25550, your program would output: You are a senior citizen Your prompt to the user to enter the number of days must be Enter an age in number of days : Please note that your class should be named AgeLabel Homework 4-3 Write a Java program that asks the user for a date entered as 4 integers dayNumber monthNumber date year. Where dayNumber An integer from 1-7, where 1 Sunday, 2 Monday. - 7 = Saturday month Number An integer from 1-12, where 1 - January, 2 - February, 12 December date An integer from 1-31 representing the date year An Integer representing the year. Your prompt to the user should be Enter integer representing daytuberonthamber dece year You program will compute the proper dayName from the specified dayNumber and the proper monthName from the specified month Number. Your program will print out the specified date in the following format daytlumber monthshmber date your lo deset date. year Please note your program will have to error check the input as follows: 1. First the dayNumber is checked for being in the range 17. If that is not the case your program should print out the following message and terminate execution Invalid day sumber dayunbazplease enter a number tram 17 2 Then the month Number is checked for being in the range 112 of that is not the case your program should print out the following message and terminate execution Invalid month numbers on the please enter = tubes from 1.12. 3. Then the date is checked for being in the range 1 31. If that is not the case, your program should print out the following message and terminate execution Invalid date mamber pleasantar mumbat fumi... 4. Then the date must be checked for validity For example, there is no February 30. February 31, April 31. June 31. September 31. November 31. the date is invaldyour program should print out the following Message and terminate Execution Invalid dater months does not have dete daye. please enter a valid date 6. Lastly, the month Number - 2. and date20 you must erity that the year entered is a leap year which is the only time that February 20 exists. Please see we only if the year a not a leap year and the user entered a date 29. your program should pret out the following message and terminate Grection Avaldata os at leap year. Tebrant Savedate days Please note that your class should be named DateConverter
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
