Софтуерно Инженерство
Loading...
+ Нов въпрос
Val3ntinV avatar Val3ntinV 0 Точки

Alcohol Market-Help 365.lv--not--315lv.

import java.util.Scanner;

public class zadachaOtUprajneniq7 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double whiskeyLeva = Double.parseDouble(scanner.nextLine());
        double biraLitri = Double.parseDouble(scanner.nextLine());
        double vinoLitri = Double.parseDouble(scanner.nextLine());
        double rakiqLitri = Double.parseDouble(scanner.nextLine());
        double whiskeyLitri = Double.parseDouble(scanner.nextLine());

        double cenaNaRakiq = whiskeyLeva*0.50;
        double cenaNaVino = cenaNaRakiq - (0.40*cenaNaRakiq);
        double cenaNaBira = cenaNaRakiq - (0.80*cenaNaRakiq );
        double sumaZaRakiq = rakiqLitri * cenaNaRakiq;
        double sumaZaVino = vinoLitri * cenaNaVino;
        double sumaBira = biraLitri * (cenaNaVino-cenaNaBira);
        double sumawhiskey = whiskeyLitri * whiskeyLeva;
        double obshtaSuma = sumaBira+sumawhiskey+sumaZaRakiq+sumaZaVino;
        System.out.printf("%.2f",obshtaSuma);


    }
}
Тагове:
0
Programming Basics with Java
mark79 avatar mark79 40 Точки

Здравей, този ред нещо не е наред според мен. Не изчисляваш цената на бирата коректно.

double sumaBira = biraLitri * (cenaNaVino-cenaNaBira);

 

По-горе в кода имаш :

double cenaNaBira = cenaNaRakiq - (0.80*cenaNaRakiq );
0
13/05/2019 19:01:22
RuNNeR4142 avatar RuNNeR4142 21 Точки

 

public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double whiskeyPrice = Double.parseDouble(scanner.nextLine());
        double beer = Double.parseDouble(scanner.nextLine());
        double wine = Double.parseDouble(scanner.nextLine());
        double raki = Double.parseDouble(scanner.nextLine());
        double whiskey = Double.parseDouble(scanner.nextLine());

        double rakiPrice = whiskeyPrice / 2;
        double winePrice = rakiPrice - (rakiPrice * 0.4);
        double beerPrice = rakiPrice - (rakiPrice * 0.8);

        double price = (whiskey * whiskeyPrice) + (beer * beerPrice) + (wine * winePrice) + (raki * rakiPrice);

        System.out.printf("%.2f", price);
    }
}

 

0