Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.
    1. Ask for a second teaspoon of sugar only if the first teaspoon of sugar was requested.
    2. If black tea is requested print "Black tea", otherwise print "Green tea".
    3. If sugar and milk are requested, print ", with milk". If milk is not requested print ", no milk". Otherwise do not print anything.
    4. If milk and sugar are requested print ", and". If sugar, but not milk is requested print " with". Otherwise do not print anything.
    5. 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.
  1. 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

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

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions

Question

If 9 x = 25, what does 3 x equal?

Answered: 1 week ago

Question

Discuss the history of human resource management (HRM).

Answered: 1 week ago