3. a. Write an application for the Summerdale Condo Sales office; the program de
ID: 3766716 • Letter: 3
Question
3. a. Write an 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, or 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.
b. 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 condo 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.
Thank you very much for all your help.You guys are great!!
Explanation / Answer
import java.io.*;
import java.util.Scanner;
class CondoSales
{
public static void main(String[] args)throws Exception
{
int view;
int additionalChoice;
double price;
boolean condoSelected=false;
Scanner in=new Scanner(System.in);
System.out.println("Select View ");
System.out.print("1)Park view 2)Golf course view 3)Lake view ");
view=in.nextInt();
in.nextLine();
switch(view){
case 1:
condoSelected=true;
price=150000;
System.out.println("You Have Selected Park View Price is $"+price);
break;
case 2:
condoSelected=true;
price=170000;
System.out.println("You Have Selected Golf Course View Price is $"+price);
break;
case 3:
condoSelected=true;
price=210000;
System.out.println("You Have Selected Lake View Price is $"+price);
break;
default:
condoSelected=false;
price=0;
System.out.println("Invalid price is $"+price);
}
if(condoSelected){
System.out.println("Eneter Details if Required 1)Garage 2)Parking Space ");
additionalChoice=in.nextInt();
if(additionalChoice==1||additionalChoice==2){
price +=5000;
System.out.println("Total Cost = $"+price+" ");
}else{
System.out.println("Total Cost =$"+price+" ");
}
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.