EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
bartleby

Videos

Question
Book Icon
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.

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.
      • Print the output.

Blurred answer
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…
Knowledge Booster
Background pattern image
Computer Science
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
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
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