Java: An Introduction to Problem Solving and Programming (8th Edition)
8th Edition
ISBN: 9780134462035
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 3, Problem 13E
Imagine a
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a short program that displays a list of coffees, like below:
The Kicking Coffee Café
$3.50
L- Latte
E- Espresso $4.15
R-Regular
1- Iced
$1.00
$2.75
The program will then ask the user to enter their preference (L for latte, etc.).
Use a switch statement to evaluate the users' choice and display a price for the coffee that
includes a 5% sales tax rate.
If none of the menu choices are selected (for example, the user enters a S), an appropriate
error message should be displayed and no price calculated.
v2
Question 6
What situation calls for a switch statement?
Group of answer choices
Use a switch statement when the switch statement is inside the main program.
Use a switch statement when a for statement can not be used.
Use a switch statement when a selection is in a repitition statement.
Use a switch statement when a single control value determines which of several possible actions is to be taken.
Use a switch statement when a selection is outside of repitition statement.
Direction: Perform what is asked below.
CASE:
Due to the present situation that we are facing, which is the pandemic, the
government decided to limit the type of rice the consumer can purchase to one. With
your help as a programmer, the government ask you to create such program. The
program should be able to display the menu as displayed below. The user will be
allowed to enter the choice, quantity in kilo grams (kg) and payment amount. The
program should also be able to output the total amount due and the change.
Organize your algorithm in such a way that it is logically correct, usable and
functional.
RICE MENU
[1] Denorado
[2]
[3] Jasmine
[4] NFA
[5] Malagkit
Senandomeng
Organic Brown Rice
P55/kg
P47 /kg
P58/kg
P38 /kg
P70/kg
P120/kg
Chapter 3 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Ch. 3.1 - Suppose goals is a variable of type int. Write an...Ch. 3.1 - Suppose goals and errors are variables of type...Ch. 3.1 - Suppose salary and deductions are variables of...Ch. 3.1 - Suppose speed and visibility are variables of type...Ch. 3.1 - Suppose salary and bonus are variables of type...Ch. 3.1 - Assume that nextWord is a string variable that has...Ch. 3.1 - Prob. 7STQCh. 3.1 - What output is produced by the following code? int...Ch. 3.1 - Suppose you change the code in the previous...Ch. 3.1 - What output is produced by the following code? int...
Ch. 3.2 - Suppose number is a variable of type int that has...Ch. 3.2 - What output is produced by the following...Ch. 3.2 - What output is produced by the following...Ch. 3.2 - What output is produced by the following...Ch. 3.3 - What output is produced by the following code?Ch. 3.3 - Suppose you change the code in the previous...Ch. 3.3 - What output is produced by the following code?Ch. 3.3 - What output is produced by the following code?Ch. 3.3 - Suppose you change the first line of the code in...Ch. 3.3 - Prob. 20STQCh. 3.4 - Suppose you change the order of the drawing...Ch. 3.4 - Prob. 22STQCh. 3.4 - Write code for a JOptionPane dialog that will ask...Ch. 3 - Write a fragment of code that will test whether an...Ch. 3 - Write a fragment of code that will change the...Ch. 3 - Suppose you are writing a program that asks the...Ch. 3 - Prob. 4ECh. 3 - Consider the following fragment of code: What is...Ch. 3 - We would like to assess a service charge for...Ch. 3 - What is the value of each of the following boolean...Ch. 3 - The following code fragment will not compile. Why?...Ch. 3 - Prob. 9ECh. 3 - Consider the boolean expression (2 5) (x 100))....Ch. 3 - Write a switch statement to convert a letter grade...Ch. 3 - Consider the previous question, but include + or ...Ch. 3 - Imagine a program that displays a menu of five...Ch. 3 - Repeat the previous exercise, but define an...Ch. 3 - Repeat Exercise 13, but use a multibranch if-else...Ch. 3 - Given that the int variable temp contains a...Ch. 3 - Write Java statements that create a yes-or-no...Ch. 3 - A number x is divisible by y if the remainder...Ch. 3 - Write a program to read in three nonnegative...Ch. 3 - Write a program that reads three strings from the...Ch. 3 - Write a program that reads a one-line sentence as...Ch. 3 - Write a program that allows the user to convert a...Ch. 3 - Write a program that inputs an integer. If the...Ch. 3 - Prob. 7PCh. 3 - Repeat Programming Project 5 of Chapter 2, but...Ch. 3 - Repeat any of the previous Practice Programs using...Ch. 3 - Suppose that we are working for an online service...Ch. 3 - Write a program that reads a string from the...Ch. 3 - Repeat the calorie-counting program described in...Ch. 3 - Repeat Programming Project 5 but in addition ask...Ch. 3 - Repeat Programming Project 11 in Chapter 2, but if...Ch. 3 - Write a program to play the rock-paper-scissor...Ch. 3 - Prob. 9PPCh. 3 - Repeat Programming Project 8 in Chapter 1, but add...Ch. 3 - Write a program that inputs two strings that...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Determine the resultant internal normal force, shear force, and bending moment at point C in the beam.
Mechanics of Materials (10th Edition)
Define a method hypotenuse that calculates the hypotenuse of a right triangle when the lengths of the other two...
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
How were the pseudocodes of the early 1950s implemented?
Concepts Of Programming Languages
Porter’s competitive forces model: The model is used to provide a general view about the firms, the competitors...
Management Information Systems: Managing The Digital Firm (16th Edition)
Why do cutting fluids for drilling usually have more lubricating qualities than those for most other machining ...
Degarmo's Materials And Processes In Manufacturing
Describe a method that can be used to gather a piece of data such as the users age.
Web Development and Design Foundations with HTML5 (8th Edition)
Knowledge Booster
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
- oln college, a student may get a grade of 1.0 (as the highest) to 5.0 (lowest). Anyone who get's a Final Grade of at most 3.0 is considered a passing grade. Create a program that will ask the user to input a student's midterm grade and tentative final grade. After calculating the student's final grade using the formula below, main() will then call on DisplayStatus() to display if the student passed the subject or not. MG + TFG FG = 2 OF THE MADE4Learners NSTITUTE FRAMEWORK VERSITY UNI MULTIPLE APPROACHES TO DISTANCE EDUCATION FOR TECHNOLOGIAN LEARNERS : O Google Slides ECHNOLOGAarrow_forwardC onlyarrow_forwardUsing Switch statement, write a program that displays the following menu for the food items available to take order from the customer: Rice = $ 12.50 Sugar= $ 4.25 Tea= $3.75 Milk= $ 1.00 The program inputs the type of food and quantity. It finally displays the total charges for the order according to following criteria: Your output should be as follows:arrow_forward
- C Program for a menu based program that uses a switch-case statement to include the following options: a) Print your name. b) Print your tutorial time. c) Prompt the user to enter a positive number between 1-50, read the entered input, and display all numbers from 0 up to the number entered (the display should print five numbers per line). E.g: if the user enters 9, the program will display 0 1 2 3 4 5 6 7 8 9 q) Quit The user should be able to continuously enter and execute options until they enter the 'q' character to quit. The algorithm should be able to accept the upper- and lower-case versions of all character input options and should be able to deal with invalid options being input for all input (including the number required for part c). Note: for the first two options, the program does not need to read in your name/tutorial time and then print this out. It simply needs to output a message that you hard code into the program. Your solution must be modular in design.…arrow_forwardIN PYTHONWrite a program that reads in a code (C for circumference and A for the area) and the radius of a circular pool, computes and displays the circumference or the area depending on the code entered. Use a switch statement for the selection. If the user enters any other character (other than C or A), the program should display that it is an invalid choice. (Formulas: Area = Πr2, Circumference = 2Πr, where Π = 3.14159, and r is the radius)arrow_forwardBody mass index (BMI) is a measure of health based on weight. It can be calculated by taking your weight in kilograms and dividing it by the square of your height in meters. Write a program that prompts the user to enter a weight in pounds and height in inches and displays the BMI. Note that one pound is 0.45359237 kilograms and one inch is 0.0254 meters.arrow_forward
- Design an Applet function to display the net amount depending on the option selection by the user (Savings/Current) assuming that the textbox, buttons, check box and labels are already defined. If user selected Savings display net amount=amount *2 If user selected Current display net amount=amount *5arrow_forwardThe game should begin by randomly dealing 2 cards to the user's hand, and then calculate and display the total. Next the program should display a prompt, asking the user if he/she wants a Hit or to Stand. If the user selects to Hit the game should randomly deal a new card to the user's hand, and then calculate and display the new total. If the total is greater than 21, then the user Busts, the house wins, and a message indicating these results is displayed. If the total is less than 21, repeat the Hit/Stand Prompt to the user. Continue this process until the user elects to Stand or Busts. If the user selects to Stand, the game then randomly deals two cards to the house, and then calculates those total points. The dealer must continue to Hit as long as the total of the House had is under 17, display the results after each Hit The dealer must Stand once the House hand reaches 17 or higher. Once If the user has not already Busted, compare the User's Hand to the House Hand and determine…arrow_forwardQuestion on picturearrow_forward
- can you please do this in java eclipse ide thank youarrow_forwardA county collects property taxes on the assessment value of property, which is 60 percent of the property’s actual value. If an acre of land is valued at $10,000, its assessment value is $6,000. The property tax is then 75¢ for each $100 of the assessment value. The tax for the acre assessed at $6,000 will be $45. Write a program that asks for the actual value of a piece of property and displays the assessment value and property tax.arrow_forward4. Option controls are choices we put on our program. True Falsearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY