In: Computer Science
Please write a java code.
Write a generic program for New Home Construction Pricing with
the following specifications.
Note, each one of the 2, 3 or 4 bedroom homes are priced with
standard type bathrooms.
Update to deluxe or premium choice of bathrooms can be ordered by
paying the difference in prices.
Types of homes Price
2 bedroom, 2 bathroom (standard type) and 1 car garage home =
$350,000
3 bedroom, 2 bathroom (standard type) and 2 car garage home =
$400,000
4 bedroom, 2 bathroom (standard type) and 2 car garage home =
$450,000
Options:
Price of full bathroom (standard type) = $20,000
Price of full bathroom (deluxe type) = $25,000
Price of full bathroom (premium type) =$30,000
Each addition of a car garage = $50,000
User Inputs:
Enter the choice of house (1 for 2 bedroom, 2 for 3 bedroom, 3 for
4 bedroom house) = 3
Enter the choice of bathroom type (1 for standard, 2 for deluxe, 3
for premium) = 3
Enter additional full bathrooms (only of same type) = 3
Enter additional car garages required = 3
Expected outcome:
Standard Price of home = $450,000
Price for modifying bathroom type = 2 (10000) = 20000
Price for adding bathrooms of same type = 30000 (3) = 90000
Price for adding car garages = 3 (50000) = 150000
Total price of home after modifications =450000+20000+90000+150000
= 710000
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
int housePrice=0,bathPrice=0;
Scanner sc = new Scanner(System.in);
System.out.print("Enter the choice
of house (1 for 2 bedroom, 2 for 3 bedroom, 3 for 4 bedroom house)
= ");
int houseChoice =
sc.nextInt();
if(houseChoice==1)
{
housePrice=350000;
}
else if(houseChoice==2)
{
housePrice=400000;
}
else if(houseChoice==3)
{
housePrice=450000;
}
System.out.print("Enter the choice
of bathroom type (1 for standard, 2 for deluxe, 3 for premium) =
");
int bathChoice =
sc.nextInt();
if(bathChoice==1)
{
bathPrice=20000;
}
else if(bathChoice==2)
{
bathPrice=25000;
}
else if(bathChoice==3)
{
bathPrice=30000;
}
System.out.print("Enter additional
full bathrooms (only of same type) = ");
int
additionalBathCount=sc.nextInt();
System.out.print("Enter additional
car garages required = ");
int
additionalgarages=sc.nextInt();
System.out.println("Standard Price
of home = $"+housePrice);
System.out.println("Price for
modifying bathroom type = 2 ("+(bathPrice-20000)+") =
"+2*(bathPrice-20000));
System.out.println("Price for adding bathrooms of same type =
"+bathPrice+" ("+additionalBathCount+") =
"+(additionalBathCount*bathPrice));
System.out.println("Price for adding car garages =
"+additionalgarages+" (50000) = "+(additionalgarages*50000));
System.out.println("Total price of home after modifications
="+housePrice+"+"+(2*(bathPrice-20000))+"+"+(additionalBathCount*bathPrice)+"+"+(additionalgarages*50000)+"
=
"+(housePrice+(2*(bathPrice-20000))+(additionalBathCount*bathPrice)+(additionalgarages*50000)));
}
}