In Java, is there a simple way of doing this without having to use so many If statements? please explain   A client wants to purchase drinks for an event they are arranging. Write a program that asks them how much money they have to spend and whether alcohol would be allowed at the event. Then show them their choices from the following list, but 1) only show drinks that they can afford to buy at least 1 of, 2) only show alcoholic drinks if they are allowed at the event, and 3) show how many of each drink they could afford. If the user enters an invalid or negative value for their budget or an invalid response for whether alcohol is allowed, it should indicate an error and let the user try again. The possible drink choices are: Bottle of Water: $0.50 Soda: $1.50 Tea: $3.00 Beer (alcoholic): $5.00 Wine (alcoholic): $20.00

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 14RQ
icon
Related questions
Question

In Java, is there a simple way of doing this without having to use so many If statements? please explain

 

A client wants to purchase drinks for an event they are arranging. Write a program that asks them how much money they have to spend and whether alcohol would be allowed at the event. Then show them their choices from the following list, but 1) only show drinks that they can afford to buy at least 1 of, 2) only show alcoholic drinks if they are allowed at the event, and 3) show how many of each drink they could afford. If the user enters an invalid or negative value for their budget or an invalid response for whether alcohol is allowed, it should indicate an error and let the user try again. The possible drink choices are: Bottle of Water: $0.50 Soda: $1.50 Tea: $3.00 Beer (alcoholic): $5.00 Wine (alcoholic): $20.00

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 9 steps with 7 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT