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
Write a standard mode application for the Summerdale Condo Sales Office; the program determines the price of a condominium. Ask the user to choose 1 for park view, 2 for golf course view, 3 for lake view. The output is the name of the chosen view as well as the price of the condo. Park view condos are $150,000, condos with golf course views are $170,000, and condos with lake views are $210,000. If the user enters an invalid code, set the price to 0. Save the file as CondoSales.java. Add a prompt to the CondoSales application to ask the user to specify a (1) garage or a (2) parking space, but only if the view selection is valid. Add $5,000 to the price of any condo with a garage. If the parking value is invalid, display an appropriate message and assume that the price is for a condo with no garage. Save the file as CondoSales2.java.
Write an application that prompts the user for two integers and then prompts the user to enter an option as follows: 1 to add the two integers, 2 to subtract the second integer from the first, 3 to multiply the integers, and 4 to divide the first integer by the second. Display an error message if the user enters an option other than 1 through 4 or if the user chooses the divide option but enters 0 for the second integer. Otherwise, display the results of the arithmetic.
Write an application that allows a user to enter any number of student test scores until the user enters 999. If the score entered is less than 0 or more than 100, display an appropriate message and do not use the score. After all the scores have been entered, display the number of scores entered, the highest score, the lowest score, and the arithmetic average. Save the file as TestScoreStatistics.cpp.
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
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