Question:
Harima Realtor’s leading Real Estate Developer. They provide independent housing layouts, apartments & individual villas at affordable price. The Management of Harima Realtor’s has planned to give a grand discount to its buyers. The discount is given based on the land area booked or purchased. Write a java program to calculate the total price the buyer needs to pay based on the discount if applicable.
Land Area(in Sq.foot) | Cost/Sq.feet(in Rupees) | Discount Rate (in percentage) |
400-599 | 1700 | 5% |
600-999 | 1900 | 5% |
1000-2400 | 2600 | 4% |
2500-3000 | 2800 | 3% |
Note:
If the Land Area is not within the range of 400-3000, the display “<Land Area> is out of range”.
Refer sample output for formatting specifications.
Sample Input 1:
Enter the buyer name
Roshan
Enter the Land area
800
Sample Output 1:
Total payable amount after discount is
1444000.0
Sample Input 2:
Enter the buyer name
Jack
Enter the Land area
300
Sample Output 2:
300 is out of range
Code:
Main.java
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double total =0; System.out.println("Enter the buyer name"); String name =sc.nextLine(); System.out.println("Enter the Land area"); int area = sc.nextInt(); sc.nextLine(); if(area>=400 && area<=599){ total = area*1700; total = total * 0.95; } else if(area>=600 && area<=999){ total = area*1900; total = total * 0.95; } else if(area>=1000 && area<=2600){ total = area*2600; total = total * 0.96; } else if(area>=2500 && area<=3000){ total = area*2800; total = total * 0.97; } else{ System.out.println(area+" is out of range"); return; } System.out.println("Total payable amount after discount is \n"+total); } }
Output:
Enter the buyer name Richal Enter the Land area 2700 Total payable amount after discount is 7333200.0