Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- // This program assumes that all inputs are correct and doesn't validate them:
- // Number of rooms - An integer between 3 and 5
- public class HouseCommittee {
- public static void main(String[] args) {
- Scanner s = new Scanner(System.in);
- int numOfRooms, price;
- boolean isDuplex;
- System.out.println("Please enter the number of rooms:");
- numOfRooms = s.nextInt();
- if(numOfRooms < 5) {
- price = numOfRooms == 3 ? 120 : 150;
- } else {
- // Check if duplex
- System.out.println("Please enter 'true' if the apartment is a duplex, or 'false' if not:");
- isDuplex = s.nextBoolean();
- price = isDuplex ? 200 : 180;
- }
- // Print the price to the console
- System.out.println("The price is: " + price + " ILS.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement