Question
Write a program in java that determines how long a human user can assign dish duties among the children in a family before making a
Write a program in java that determines how long a human user can assign dish duties among the children in a family before making a mistake. Use Console I/O (Scanner and System.out) for all input/output. Follow the directions carefully and be particularly careful to write methods when directed, instead of stuffing main() with code that should be elsewhere. Write a method that takes user input to create a list of the names of the children in the family. This method must be able to create a list of any number of names, including zero. You can ask the user first for the number of children, and then use a for loop to take that number of names from input and add them to the list, but there are several other possible approaches. This method must return a reference to the list. Do not give the list class scope. In main(), write a loop that calls the method described above, keeping a reference to the list it returns, and then offers a menu with three options: Quit, Hard Problem, and Easy Problem. The user must be able to repeat this exercise as many times as he or she wants to, providing a new list of names each time, and the program must not terminate until the user chooses to quit. Implement the hard and easy problems in separate methods, not inside main(). Each of these methods will take a List of Strings as its only parameter and return an int. In the main loop, use a switch based on the user's input to call the method that corresponds to the user's choice of hard or easy problem. Send a reference to the List of names in the method call. Within the method for each problem, use a loop that increments the day by one for each iteration, and use a modulo operation to determine which child is responsible for dish duties each day. The Three Stooges example in the review lecture may be helpful. Get the name using the index and List's get(int index) method. For the easy problem, construct Strings that contain the day number (starting with 0) and the name of the child who should do the dishes. For day 0, the String should be similar to "Day 0: Bob must do the dishes." For the hard problem, just get the name of the child who is responsible for the dishes on each day. For the easy problem, output the correct String and require the user to copy the whole String back at the console prompt. For the hard problem, just provide the prompt "input: " and test whether the String input by the user is identical to the name of the child. For each iteration of the loop, test the input to see if it matches the correct answer. Use a boolean variable that is set to true if the input is correct and set to false when the user makes an error. The loop test should fail when the value of this boolean is false. Don't use a break() statement for this. The method should return an int, which represents the number of times the user provided the correct input. Print this result form to the main
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started