EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
expand_more
expand_more
format_list_bulleted
Question
Chapter 5, Problem 3PE
a.
Program Plan Intro
Determine the price of a selected room
Program plan:
- Import necessary package.
- Create a class “ShadyRestRoom”,
- Define the method “main ()”,
- Declare the necessary variables.
- Declare the necessary final variables.
- Create “Scanner” object.
- Print the menu.
- Prompt the user to enter the choice.
- Get the choice from the user using “nextInt()”.
- Check whether the choice is queen,
- Assign the corresponding text for a queen.
- Assign the corresponding price for a room.
- Otherwise, check whether the choice is a king,
- Assign the corresponding text for a king.
- Assign the corresponding price for a room.
- Otherwise, check whether the choice is a suite,
- Assign the corresponding text for a suite.
- Assign the corresponding price for a suite.
- Otherwise,
- Assign the invalid text.
- Set the price value to “0”.
- Print the output.
- Define the method “main ()”,
b.
Program Plan Intro
Determine the price of a selected view
Program plan:
- Import necessary package.
- Create a class “ShadyRestRoom2”,
- Define the method “main ()”,
- Declare the necessary variables.
- Declare the necessary final variables.
- Create “Scanner” object.
- Print the menu.
- Prompt the user to enter the choice.
- Get the choice from the user using “nextInt()”.
- Check whether the choice is queen,
- Assign the corresponding text for a queen.
- Assign the corresponding price for a room.
- Otherwise, check whether the choice is a king,
- Assign the corresponding text for a king.
- Assign the corresponding price for a room.
- Otherwise, check whether the choice is a suite,
- Assign the corresponding text for a suite.
- Assign the corresponding price for a suite.
- Otherwise,
- Assign the invalid text.
- Set the price value to “0”.
- Check whether the price is not equal to “0”,
- Prompt the user to enter the view.
- Print the view and the corresponding text.
- Prompt the user to enter the choice of view.
- Get the view choice from the user.
- Check whether the choice is lake,
- If it is true, assign the corresponding text for a lake.
- Update the price.
-
- Otherwise, check whether the choice is a park,
- If it is true, assign the corresponding text for a park.
- Otherwise,
- Update the price.
- Assign the error text message.
- Otherwise, check whether the choice is a park,
- Print the output.
- Define the method “main ()”,
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
In C#, please?
Write a program named CheckMonth2 that prompts a user to enter a birth month and day.
Display an error message that says Invalid date if the month is invalid (not 1 through 12) or the day is invalid for the month (for example, not between 1 and 31 for January or between 1 and 29 for February).
If the month and day are valid, display them with a message. For example, if the month entered is 2, and the day entered is 17, the output should be 2/17 is a valid birthday.
Part A
Write an application called ShadyRestRoom for the Shady Rest Hotel; the program determines the price of a room. Ask the user to choose 1 for a queen bed, 2 for a king, or 3 for a king and a pullout couch. The output echoes the input and displays the price of the room: $125 for queen, $139 for king, and $165 for a suite with a king bed and a pullout couch. If the user enters an invalid code, display an appropriate message and set the price to 0.
An example of the program is shown below:
Menu (1) Queen bed (2) King bed (3) Suite with a king bed and pull-out couch Enter Selection (1, 2, or 3) >> 2 You selected King bed $139
Part B
Copy the contents of the ShadyRestRoom application into ShadyRestRoom2.java file and rename the class ShadyRestRoom2. Add a prompt to the ShadyRestRoom application to ask the user to specify a (1) lake view or a (2) park view, but ask that question only if the bed size entry is valid. Add $15 to the price of any room with a lake view. If the view…
Assume that the population of Mexico is 128 million and the population of the United States is 323 million. Write a program called Population that accepts two values from a user: an assumption of an annual increase in the population of Mexico and an assumption for an annual decrease in the U.S. population. Accept both figures as percentages; in other words, a 1.5 percent decrease is entered as 0.015. Write an application that displays the populations of the two countries every year until the population of Mexico exceeds that of the United States, and display the number of years it took.
An example of the program is shown below:
Enter the percent annual increase for Mexico population
Enter as a decimal.
For example, 0.5% is entered as 0.005 Enter the value >> 0.008
Enter the percent annual decrease for U.S. population
Enter as a decimal.
For example, 0.5% is entered as 0.005
Enter the value >> 0.002
Mexico population U.S. Population 1 129.024 million 322.354 million 2…
Chapter 5 Solutions
EBK JAVA PROGRAMMING
Ch. 5 - Prob. 1RQCh. 5 - Prob. 2RQCh. 5 - Prob. 3RQCh. 5 - Prob. 4RQCh. 5 - Prob. 5RQCh. 5 - Prob. 6RQCh. 5 - Prob. 7RQCh. 5 - Prob. 8RQCh. 5 - Prob. 9RQCh. 5 - Prob. 10RQ
Ch. 5 - Prob. 11RQCh. 5 - Prob. 12RQCh. 5 - Prob. 13RQCh. 5 - Prob. 14RQCh. 5 - Prob. 16RQCh. 5 - Prob. 17RQCh. 5 - Prob. 18RQCh. 5 - Prob. 19RQCh. 5 - Prob. 20RQCh. 5 - Prob. 1PECh. 5 - Prob. 2PECh. 5 - Prob. 3PECh. 5 - Prob. 4PECh. 5 - Prob. 5PECh. 5 - Prob. 6PECh. 5 - Prob. 7PECh. 5 - Prob. 8PECh. 5 - Prob. 9PECh. 5 - Prob. 10PECh. 5 - Prob. 1GZCh. 5 - Prob. 2GZCh. 5 - Prob. 3GZCh. 5 - Prob. 4GZCh. 5 - Prob. 5GZ
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
- Write a program in C# Write an application named DailyTemps that continuously prompts a user for a series of daily high temperatures until the user enters a sentinel value of 999. Valid temperatures range from -20 through 130 Fahrenheit. When the user enters a valid temperature, add it to a total; when the user enters an invalid temperature, display the error message:Valid temperatures range from -20 to 130. Please reenter temperature.Before the program ends, display the number of temperatures entered and the average temperature.arrow_forward. Write an application for a college’s admissions office. Prompt the user for a student’s numeric high school grade point average (for example, 3.2) and an admission test score from 0 to 100. Display the message “Accept” if the student has any of the following: A grade point average below 3.0 and an admission test score of at least 80 If the student does not meet either of the qualification criteria, display “Reject”. Save the file as Admission.java.arrow_forwardcreate an application that will find the largest and the smallest number of a series of integers input by the user. Assume that the user will input only integers that are between -100 and 100 (both inclusive) (no need to validate the input). When the user inputs 101, the application should output the smallest and the largest number.arrow_forward
- You are required to write a code that requests the user to enter three integer coefficients: a, b, and c in this order. Next, the user is requested to enter the equation degree: 1 for a linear equation and 2 for a quadratic equation. If the user enters an equation degree other than 1 or 2, the program must output Invalid. Based on the equation type, the program will process the coefficients and provide outputs as described below: First Scenario: Linear Equation When a linear equation is selected, the coefficient a is ignored and the equation format becomes: y=bx+c The program should check the slope of the line and accordingly print the values of the x-intercept, the y-intercept, and the line direction with respect to the x-axis each on a separate line. We have four possibilities: Slope is positive (i.e. b > 0): x-intercept = −cb, y-intercept = c, direction is UpwardSlope is negative (i.e. b < 0): x-intercept = −cb, y-intercept = c, direction is DownwardSlope is zero (i.e. b = 0)…arrow_forwardScenario:The owner of 'Cupcakes R Us' is in need of a web application to sell their bakery products via ecommerce. Cupcakes R Us sells cupcakes, cookies, and cakes. They do not have a storefront. Therefore, they need a web site to sell their baked goods. The user enters their name, state, bakery item and the quantity (by dozen or cake) for as many items they want to purchase. The program validates all data entered the name can not be blank the state can only be the three states listed above. the bakery item must be a valid bakery item from the list above. the quantity can not <= 0 If the values are invalid, an error message is displayed to the user Otherwise: the values for the item and quantity are added to an array of items selected to be purchased. The program computes the subtotal, and calculates the tax based on the state. The application provides the following information at the bottom of the page : Name of Client (in proper case), State, the list of items selected to be…arrow_forwardUsing C++, write a program for a "6/15 Lottery Game". Please take note of the following: 1. It must only request the user to enter a digit between 0 and 15, six times. It must be specified in the output display that it is "1st digit", "2nd digit", and so on up to "6th digit". 2. If the digit entered is more than 15, the application will notify the player by displaying the following message: "Error! Please only enter digits between 0 and 15! Repeat your choice!" And the program will be terminated. 3. If at least one digit from the Lottery draw matched (precise array position and digit), the output display must be, for example: "1 Match! Your bet is now available for the next draw!" 4. If no digit from the Lottery draw matched, the output display must be, for example: "No Exact Match Found; Please Retry!" 5. Note that repetition of input digit chosen by the player is allowed. 6. And finally, if all digit matches, it will give an output display, as an example: "Congratulations!"arrow_forward
- To rt z98.arrow_forwardCode is in Python Write an application that allows the user to enter a call number of a book, and if the book islocated, the location will be displayed. The application will continue to ask the user for a callnumber until the user enters -1 to exit the application. Below is the call numberlegend you will need to return the correct output. Make sure to pay close attentionto the conditional requirements for each output. Call Numbers and their locations are: 99 and below = Book not found! 100-199 = Basement 200-500 and over 900 = Main Floor 501-900 except 700-750 = Upper Floor 700-750 = Archives Copy the source code give in the picture. NOTE: The application won’t return the correctoutput until you add them accordingly Use the call number legend table above to return the correct outputs. Currently,the application will return empty…arrow_forwardPrint "user_num1 is negative." if user_num1 is less than 0. End with newline. Assign user_num2 with 3 if user_num2 is greater than 13. Otherwise, print "user_num2 is less than or equal to 13.". End with newline.arrow_forward
- sandbox $ + Q Search this course ?.arrow_forwardcan you help me to do this java codearrow_forward5. A store is having a (Buy One, Get One Half Off) sale. The store manager wants an application that allows the salesclerk to enter the prices of two items. The half off should always be applied to the item that has the lowest price. The application should calculate and display the total amount the customer owes as well as the amount he or she saved. For example, if the two items cost $24.99 and $10.00, the half off is applied to the $10.00 item. The total owed is $29.99 and the savings is $5.00. Display the calculated amounts in label controls, and display them with a dollar sign and two decimal places. Finally, professionalize your application's interface.arrow_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,Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
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,
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
C - File I/O; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=cEfuwpbGi1k;License: Standard YouTube License, CC-BY
file handling functions in c | fprintf, fscanf, fread, fwrite |; Author: Education 4u;https://www.youtube.com/watch?v=aqeXS1bJihA;License: Standard Youtube License