Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Delete {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double cenaNaEkskurziqta = Double.parseDouble(scanner.nextLine());
- double broiPuzeli = Double.parseDouble(scanner.nextLine());
- double broiGovoreshtiKukli = Double.parseDouble(scanner.nextLine());
- double broiPlusheniMecheta = Double.parseDouble(scanner.nextLine());
- double broiMinioni = Double.parseDouble(scanner.nextLine());
- double broiKamioncheta = Double.parseDouble(scanner.nextLine());
- double resultSuma=broiPuzeli*2.60+broiGovoreshtiKukli*3+broiPlusheniMecheta*4.10+broiMinioni*8.20+broiKamioncheta*2;
- double resultSumaBroiIgrachki=broiPuzeli+broiGovoreshtiKukli+broiPlusheniMecheta+broiMinioni+broiKamioncheta;
- double resultOtstupka=0;
- double resultNaem=0;
- if(resultSumaBroiIgrachki>=50){ // >= 50 вместо >50, защото в условието пише поне 50 играчки
- resultOtstupka=resultSuma*0.25;
- resultSuma=resultSuma-resultOtstupka; // тук Math.abs е ненужно
- }
- resultNaem=resultSuma*0.10; // този код се изпълняваше независимо от резултата на проверката,
- resultSuma=resultSuma-resultNaem; // преместих го след нея, за да не се повтаря
- if (resultSuma >= cenaNaEkskurziqta) // това е проверката, която нямаш
- {
- System.out.printf("Yes! %.2f lv left.",resultSuma - cenaNaEkskurziqta);
- }
- else
- {
- double resultNedostigat=cenaNaEkskurziqta-resultSuma;
- System.out.printf("Not enough money! %.2f lv needed.",resultNedostigat);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement