Question
Create a Java program by following the directions below: Write an application for the Crystal Beach Resort; the program determines the price of a room.
Create a Java program by following the directions below:
Write an application for the Crystal Beach Resort; the program determines the price of a room. Ask the user to choose 1 for queen bed, 2 for king bed, or 3 for a king and a pullout couch. The output echoes the input and displays the price of the room. The queen beds cost $125, the king beds cost $139, and the king/sofa suite costs $165 . If the user enters an invalid room option (something other than 1, 2, or 3) an error message is displayed and the price is set to $0 (see Run 2).
Add a prompt to the Crystal Beach Resort to ask the user to specify a 1 for lake view, 2 for park view, but only ask if a valid room option was selected. Add $15 to the price of a lake view room and no charge for a park view. If this option is invalid, add $15 for a lake view (see Run 3).
How to start the program: // Ch5 Crystal Beach Resort import java.util.Scanner; public class Ch5sample { public static void main (String args[]) { // Define variables int selection, price; String result, view = "no"; // Define Constants final int QPRICE = 125, KPRICE = 139, SPRICE = 165; final String QUEEN = "Queen bed", KING = "King bed", SUITE = "Suite with a king bed and pull-out couch", INVALIDOPTION = "an invalid option"; final int LPREMIUM = 15; final String LAKE = "a lake", PARK = "a park", INVALIDVIEW = "an invalid view, so using lake"; // Display room menu Scanner in = new Scanner(System.in); System.out.println("\t Menu "); System.out.println("(" + 1 + ") " + QUEEN); // finish room menu and program // hint: after the menu, need to input the selection, then check the selection using IF/ELSE statements Example: // Check Menu selection if(selection == 1) { result = QUEEN; // using the constants defined above price = QPRICE; }
of Program Run: Menu (1) Queen bed (2) King bed (3) Suite with a king bed and pull-out couch Enter Selection (1,2, or 3)3 Please choose a view: (1) a lake (2) a park Enter Selection (1 or 2) 1 You selected Suite with a king bed and pull-out couch with a lake view for $180 Menu (1) Queen bed (2) King bed (3) Suite with a king bed and pull-out couch Enter Selection (1,2, or 3)6 You selected an invalid option with no view for $0 Menu (1) Queen bed (2) King bed (3) Suite with a king bed and pull-out couch Enter Selection (1,2, or 3)1 Please choose a view: (1) a lake (2) a park Enter Selection (1 or 2) 4 You selected Queen bed with an invalid view, so using lake view for $140Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started