Advertisement
Guest User

Untitled

a guest
Jun 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. package pb1;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Wednesday2 {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         int kmDistance = Integer.parseInt(scanner.nextLine());
  9.         int razhodLit = Integer.parseInt(scanner.nextLine());
  10.         double dizelLit = Double.parseDouble(scanner.nextLine());
  11.         int sum = Integer.parseInt(scanner.nextLine());
  12.         int razhodKola = (kmDistance * razhodLit) / 100;
  13.         double wholeRazhod = razhodKola * dizelLit;
  14.         double nalichni = wholeRazhod - sum;
  15.         if (nalichni >= wholeRazhod) {
  16.             System.out.printf("You can take a trip. %.2f money left.", nalichni);
  17.         } else if (nalichni < wholeRazhod) {
  18.             System.out.printf("Sorry, you cannot take a trip. Each will receive %.2f money.", nalichni / 4);
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement