Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package _02_ConditionalStatements;
- import java.util.Scanner;
- public class Shopping {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double budget = Double.parseDouble(scanner.nextLine());
- int videoCount = Integer.parseInt(scanner.nextLine());
- int processorsCount = Integer.parseInt(scanner.nextLine());
- int ramCount = Integer.parseInt(scanner.nextLine());
- double videoPrice = videoCount * 250.0;
- double processorsPrice = processorsCount * (videoPrice * 0.35);
- double ramPrice = ramCount * (videoPrice * 0.10);
- double sumPrice = videoPrice + processorsPrice + ramPrice;
- if (videoCount > processorsCount) {
- sumPrice = sumPrice - (sumPrice * 0.15);
- // sumPrice = sumPrice * 0.85;
- }
- double diff = Math.abs(budget - sumPrice);
- if (budget >= sumPrice) {
- System.out.printf("You have %.2f leva left!", diff);
- } else {
- System.out.printf("Not enough money! You need %.2f leva more!", diff);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement