Question

In: Computer Science

Please write a java code. Write a generic program for New Home Construction Pricing with the...

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

Solutions

Expert Solution

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)));
   }
}



Related Solutions

write a java code Write a generic program to compute the sum of 30 terms of...
write a java code Write a generic program to compute the sum of 30 terms of the following series. (181 - 5)/31 + (186 + 9)/34 - (191 - 13)/37 + (196 + 17)/40 + . . . . . 1 5 11 Note: the 3rd, 6th, 9th term etc, has a negative sign in front of parenthesis. User Input: None Expected output: Term Ratio Sum 1 5.677 5.677 2 5.735 11.413 3 -4.811 6.602
Please write the code JAVA Write a program that allows the user to enter the last...
Please write the code JAVA Write a program that allows the user to enter the last names of five candidates in a local election and the number of votes received by each candidate. The program should then output each candidate’s name, the number of votes received, and the percentage of the total votes received by the candidate. Your program should also output the winner of the election. A sample output is: Candidate      Votes Received                                % of Total Votes...
Java please! Write the code in Exercise.java to meet the following problem statement: Write a program...
Java please! Write the code in Exercise.java to meet the following problem statement: Write a program that will print the number of words, characters, and letters read as input. It is guaranteed that each input will consist of at least one line, and the program should stop reading input when either the end of the file is reached or a blank line of input is provided. Words are assumed to be any non-empty blocks of text separated by spaces, and...
Create a new Java program named AllAboutMe (For JAVA we use blue J) Write code to...
Create a new Java program named AllAboutMe (For JAVA we use blue J) Write code to have the program print your name, favorite color, and three hobbies to a new text file called “AllAboutMe” using PrintStream. Submit code.
JAVA CODE FOR BEGINNERS!! DON'T USE FOR OR WHILE METHODS PLEASE! Write a program that reads...
JAVA CODE FOR BEGINNERS!! DON'T USE FOR OR WHILE METHODS PLEASE! Write a program that reads three strings from the keyboard. Although the strings are in no particular order, display the string that would be second if they were arranged lexicographically.
Please show screenshot outputs and fully functional code for the Java program. Write the following methods...
Please show screenshot outputs and fully functional code for the Java program. Write the following methods to   1) read the content of an array of 5 doubles public static double[] readingArray() 2) find and print:the smallest element in an array of 5 double public static void smallest(double [] array) 3) find and print:the largest element in an array of 5 doubles pubic static void largest (double [] array) In the main method - invoke readingArray and enter the following numbers...
Program in Java code Write a program with total change amount in pennies as an integer...
Program in Java code Write a program with total change amount in pennies as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. .Ex1: If the input is: 0 the output is:    No change            Ex2: If the input is:    45   the output is:   1 Quarter 2 Dimes
Write a generic method in java code public static double jaccard(HashSet A, HashSet B) that on...
Write a generic method in java code public static double jaccard(HashSet A, HashSet B) that on input two sets represented as hash sets, returns their Jaccard similarity. The following are a few sample runs: Input :    A=1, 2, 3, 4,   B=2, 4, 6, 8 Return:   0.3333333333333333 Input :    A=Larry, Michael, Shaq, Kobe, LeBron                    B=Steve, Kobe, Shaq, LeBron, Steph, Jeremy, Michael Return:   0.5 Your method must have time complexity On and space complexity O1, where n is the size of...
URGENT!! DO THIS CODE IN JAVA Write a complete Java FX program that displays a text...
URGENT!! DO THIS CODE IN JAVA Write a complete Java FX program that displays a text label and a button.When the program begins, the label displays a 0. Then each time the button is clicked, the number increases its value by 1; that is each time the user clicks the button the label displays 1,2,3,4............and so on.
Write a generic method mergeSort based on the sort program of Fig. 19.6 (the source code...
Write a generic method mergeSort based on the sort program of Fig. 19.6 (the source code is given as a separate file along with this final document, and also appended at the end of this document). Test your program that prints before sorting, sorts, and prints after sorting an Integer array, a Double array, and a String array as follows:       Integer[] dataInt = {63, 19, 65, 38, 26, 74, 27, 25, 70, 38};       Double[] dataDouble = {102.5, 1.98,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT