Java Program for Harima Realtor’s Example

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-59917005%
600-99919005%
1000-240026004%
2500-300028003%

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

Recommended:

Leave a Comment

Your email address will not be published. Required fields are marked *

x