Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package jeanfrancois_o_lawnproject;
- import java.util.Scanner;
- public final class Jeanfrancois_o_LawnProject {
- private Jeanfrancois_o_LawnProject() { }
- private static final String[] MONTH_NAMES = {
- "January",
- "February",
- "March",
- "April",
- "May",
- "June",
- "July",
- "August",
- "September",
- "October",
- "November",
- "December"
- };
- int building;
- int apartment;
- int floor;
- int month;
- //This is to give error if your input is wrong.
- @SuppressWarnings("empty-statement")
- public static void main(String[] args) {
- System.out.println("Hi and welcome to Green Lawn Properties please input the following!");
- Scanner olivier = new Scanner(System.in);
- System.out.println("What's the building number?");
- int building = olivier.nextInt();
- if ((building <= 0) || (building >= 16)) {
- System.out.println("Error 404 wrong building #.");
- return;
- }
- System.out.println("What's the apartment number?");
- int apartment = olivier.nextInt();
- if ((apartment <= 100) || (apartment >= 1513));
- {
- System.out.println("Error 404 wrong apartment #.");
- return;
- }
- System.out.println("What's the month number?");
- int month = olivier.nextInt();
- if ((month < 0) || (month > 12)) {
- System.out.println("Error 404 wrong month #.");
- return;
- }
- System.out.println("What is your floor number?");
- int floor = olivier.nextInt();
- if ((floor < 0) || (floor > 4)) {
- System.out.println("Error 404 wrong floor #.");
- }
- int cost = 0;
- if (floor == 1) {
- cost = 650;
- } else if (floor == 2) {
- cost = 750;
- } else if (floor == 3) {
- cost = 850;
- }
- if (building >= 1 && building <= 5) {
- cost += cost * 0.30;
- } else if (building >= 6 && building <= 10) {
- cost += cost * 0.20;
- }
- if (month == 6 || month == 12) {
- // TODO: apply discount
- }
- System.out.println ("Green Lawn Properties");
- System.out.println("Month: " + MONTH_NAMES[month - 1]); System.out.println("Coupon Number:!");
- System.out.println("Building #" + building);
- System.out.println("Floor #" + floor);
- System.out.println("Apartment #" + apartment); System.out.println("Amount due: " + cost);
- olivier.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement