Textbook Section 3.19 Homework 3-1
Write a program that computes the fare on Copenhagen Transit given two inputs from the user:
Your prompts to the user must be:
Enter zone number : Enter adult or child :
The fare on Copenhagen Transit is specified as follows:
Your output must be of the format:
The fare for adultOrChild to zone number zoneNumber is fare.
Please note that your class should be named CopenhagenTransit.
Textbook Section 3.20 Homework 3-2
Write a program that asks the user for their age in days. The program will compute the person's age in years and then prints one of the following messages:
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 If 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 your age in number of days:
Please note that your class should be named AgeLabel.
Textbook Section 3.21 Homework 3-3
Write a Java program that asks the user for a date entered as 4 integers: dayNumber monthNumber date year. Where:
Your prompt to the user should be:
Enter 4 integers representing dayNumber monthNumber date year:
You program will compute the proper dayName from the specified dayNumber and the proper monthName from the specified monthNumber. Your program will print out the specified date in the following format:
dayNumber monthNumber date year is dayName monthName date, year
Please note your program will have to error check the input as follows:
Please note your program will have to error check the input as follows:
Invalid day number: dayNumber, please enter a number from 1..7.
Invalid month number: monthNumber, please enter a number from 1..12.
Invalid date number: date, please enter a number from 1..31.
Invalid date: monthName, does not have date days, please enter a valid date.
Invalid date: year is not a leap year, February does not have date days, please enter a valid date.
Please note that your class should be named DateConverter.
Textbook Section 3.22 Homework 3-4
Write a Java program that asks the user for four words: word1 word2 word3 word4.
Your prompts to the user must be:
Enter 4 words:
A sample runs would look like:
Enter 4 words: she groans third downlow Word 1 = "she" Length = 3 position of 'h' = 1 Word 2 = "groans" Length = 6 position of 'o' = 2 Word 3 = "third" Length = 5 position of "hi" = 1 Word 4 = "downlow" Length = 7 position of "low" = 4 Word 1 is not equal to Word 2 or Enter 4 words: shoe shoe chime glow Word 1 = "shoe" Length = 4 position of 'h' = 1 Word 2 = "shoe" Length = 4 position of 'o' = 2 Word 3 = "chime" Length = 5 position of "hi" = 1 Word 4 = "glow" Length = 4 position of "low" = 1 Word 1 is equal to Word 2
Please note that your class should be named Words.
Please submit the completed assignment in the corresponding section(s) in your textbook Lehman College, City University of New York CMP 167 Fakhouri Fall 2016: Programming in Java with zyLabs . No other forms of submission will be accepted.