Question: I cannot seem to get the default to be printed can you help edit my code please the below is the error output and the
I cannot seem to get the default to be printed can you help edit my code please the below is the error output and the instructions on the lab. I was suggested to do an if else statement? but i dont understand.
import java.util.Scanner;
public class ApartmentSales {
public static void main(String[] args) { int view,parkingOption; int estimatedprice; String str=""; Scanner sc=new Scanner(System.in);
System.out.println("Please select a view :(1) Park (2) Golf Course (3) lake "); view=sc.nextInt(); switch(view) { case 1: estimatedprice=150000; str+="Park view "; break; case 2: estimatedprice=170000; str+="Golf course view"; break; case 3: estimatedprice=210000; str+="Lake view"; break; default: estimatedprice=0; System.out.println("Error: invalid choice of view."); break; }
if(view 0){ System.out.println("Please select a Parking option :(1) Garage (2) Space "); parkingOption=sc.nextInt();
switch(parkingOption) { case 1: estimatedprice+=5000; str+=" with a garage"; break; case 2: str+=" with a parking space "; estimatedprice+=0; break; default : System.out.println("Error: invalid parking option"); estimatedprice+=0; break; } } System.out.println("Your Choice:"+str); System.out.println("Estimated Price :$"+estimatedprice); }
}


3.17 Lab 3b Due 07-Mar-17 14 pts Students This content is controlled by your instructor, and is not zyBooks content. Direct questions or concerns about this content to your instructor. If you have any technical issues with the zyLab submission system, use the "Trouble with lab?" button at the bottom of the lab Introduction This lab consists of more practice with flow control. You can either use if or switch statements, either would be appropriate. Let's Sell Some Apartments ApartmentSales java You've been hired to automate the Summerdale Sales Office's apartment price estimation system. It will need to: Ask the user to choose: 1 for park view 2 for golf course view 3 for lake view Park view apartments are $150k, apartments with gold course views are $170k, and apartments with the lake views are $210k. If the user enters an invalid code, set the price to 0 It should also ask the user to specify if they want a: 1 garage 2 parking space but only if the view selection is valid. Add $5k to the price of any apartment with a garage. If the parking vaule is invalid, display an appropriate massage and assume that the price for a apartment with no garage. Sample expected output for a park view with a parking space: Please select a view: (1) Park (2) Golf Course (3) Lake Please select a parking option (1) Garage (2) Space Your choice Park view with a parking space Estimated price: $150 000
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
