Advertisement
mmayoub

Ex02, 05.06.2021

Jun 5th, 2021
1,038
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Ex02 {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner in = new Scanner(System.in);
  7.         int x, cars;
  8.         int price;
  9.         System.out.println("enter number of persons: ");
  10.         x = in.nextInt();
  11.  
  12.         // cars with 4 passengers
  13.         cars = x / 4;
  14.  
  15.         // any one left ??
  16.         if (x % 4 > 0) {
  17.             // one more car
  18.             cars = cars + 1;
  19.         }
  20.  
  21.         System.out.println("cars = " + cars);
  22.         price = 530 * cars;
  23.         System.out.println("Total taxi price = " + price);
  24.         System.out.println("person should pay " + price / x + " shekel");
  25.         in.close();
  26.     }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement