Question
Assignment 9.2: Tea for True (10 pts) Mr. Boole is a college professor and you have been invited to his home for tea. During your
Assignment 9.2: Tea for True (10 pts)
Mr. Boole is a college professor and you have been invited to his home for tea. During your visit you can discuss anything you want. However, when he asks what you want for tea, you must answer true or false to his questions. In this assignment, you will write a program to simulate asking questions about how you want your tea and then summarize the beverage choice.
Project Specifications
- Complete each of the following Boolean logic problems and code your solutions into the worksheet after the labeling comments. See the Example Runs to verify the correctness of each computation.
- Ask for a second teaspoon of sugar only if the first teaspoon of sugar was requested.
- If black tea is requested print "Black tea", otherwise print "Green tea".
- If sugar and milk are requested, print ", with milk". If milk is not requested print ", no milk". Otherwise do not print anything.
- If milk and sugar are requested print ", and". If sugar, but not milk is requested print " with". Otherwise do not print anything.
- If no sugar is requested print " unsweetened". Otherwise print either ("one" or "two") teaspoons of sugar depending on the amount of sugar requested.
- Example Output: The input prompts and outputs of the program must look like the following for full credit, including the same order of input and exact wording of the output. For the input shown you must get the same output. However, the output must change properly if the inputs are different.
-
We have two types of tea, Black and Green. Would you like Black tea? true Would you like milk in your tea? true Would you like sugar? true Would you like more sugar? false Black tea, with milk, and one teaspoon of sugar.
We have two types of tea, Black and Green. Would you like Black tea? true Would you like milk in your tea? true Would you like sugar? true Would you like more sugar? true Black tea, with milk, and two teaspoons of sugar.
We have two types of tea, Black and Green. Would you like Black tea? false Would you like milk in your tea? false Would you like sugar? false Green tea, no milk, unsweetened.
In the above example outputs, the user entered the values shown in aqua italics (for emphasis) to produce the output. Your program does NOT print the characters in aqua italics, nor does the user input appear in aqua italics.
- Hint: Use the nextBoolean() method for the Scanner.
- After displaying the output, exit the program.
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