Advertisement
Guest User

Untitled

a guest
Aug 30th, 2017
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.84 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Delete {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         double cenaNaEkskurziqta = Double.parseDouble(scanner.nextLine());
  7.         double broiPuzeli = Double.parseDouble(scanner.nextLine());
  8.         double broiGovoreshtiKukli = Double.parseDouble(scanner.nextLine());
  9.         double broiPlusheniMecheta = Double.parseDouble(scanner.nextLine());
  10.         double broiMinioni = Double.parseDouble(scanner.nextLine());
  11.         double broiKamioncheta = Double.parseDouble(scanner.nextLine());
  12.         double resultSuma=broiPuzeli*2.60+broiGovoreshtiKukli*3+broiPlusheniMecheta*4.10+broiMinioni*8.20+broiKamioncheta*2;
  13.         double resultSumaBroiIgrachki=broiPuzeli+broiGovoreshtiKukli+broiPlusheniMecheta+broiMinioni+broiKamioncheta;
  14.         double resultOtstupka=0;
  15.         double resultNaem=0;
  16.         if(resultSumaBroiIgrachki>=50){ // >= 50 вместо >50, защото в условието пише поне 50 играчки
  17.             resultOtstupka=resultSuma*0.25;
  18.             resultSuma=resultSuma-resultOtstupka; // тук Math.abs е ненужно
  19.         }
  20.         resultNaem=resultSuma*0.10;       // този код се изпълняваше независимо от резултата на проверката,
  21.         resultSuma=resultSuma-resultNaem; // преместих го след нея, за да не се повтаря
  22.        
  23.         if (resultSuma >= cenaNaEkskurziqta) // това е проверката, която нямаш
  24.         {
  25.             System.out.printf("Yes! %.2f lv left.",resultSuma - cenaNaEkskurziqta);
  26.         }
  27.         else
  28.         {
  29.             double resultNedostigat=cenaNaEkskurziqta-resultSuma;
  30.             System.out.printf("Not enough money! %.2f lv needed.",resultNedostigat);
  31.         }
  32.     }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement