Advertisement
eranseg

House Committee

Jul 24th, 2019
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. // This program assumes that all inputs are correct and doesn't validate them:
  4. // Number of rooms - An integer between 3 and 5
  5. public class HouseCommittee {
  6.     public static void main(String[] args) {
  7.         Scanner s = new Scanner(System.in);
  8.         int numOfRooms, price;
  9.         boolean isDuplex;
  10.         System.out.println("Please enter the number of rooms:");
  11.         numOfRooms = s.nextInt();
  12.         if(numOfRooms < 5) {
  13.             price = numOfRooms == 3 ? 120 : 150;
  14.         } else {
  15.             // Check if duplex
  16.             System.out.println("Please enter 'true' if the apartment is a duplex, or 'false' if not:");
  17.             isDuplex = s.nextBoolean();
  18.             price = isDuplex ? 200 : 180;
  19.         }
  20.         // Print the price to the console
  21.         System.out.println("The price is: " + price + " ILS.");
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement