Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package S2_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 videoCardsCount = Integer.parseInt(scanner.nextLine());
- int processorsCount = Integer.parseInt(scanner.nextLine());
- int ramCount = Integer.parseInt(scanner.nextLine());
- double videoCardsPrice = videoCardsCount * 250.0;
- double processorsPrice = processorsCount * (videoCardsPrice * 0.35);
- double ramPrice = ramCount * (videoCardsPrice * 0.10);
- double totalSum = videoCardsPrice + processorsPrice + ramPrice;
- if(videoCardsCount > processorsCount) {
- //totalSum = totalSum - (totalSum * 0.15);
- totalSum = totalSum * 0.85;
- }
- double diff = Math.abs(totalSum - budget);
- if(budget >= totalSum) {
- 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