Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package L02_ConditionalStatements;
- import java.util.Scanner;
- public class P07_Shopping {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double budget = Double.parseDouble(scanner.nextLine());
- int countVideoCard = Integer.parseInt(scanner.nextLine());
- int countProcessor = Integer.parseInt(scanner.nextLine());
- int countRam = Integer.parseInt(scanner.nextLine());
- double priceVideoCard = countVideoCard * 250;
- double priceProcessors = countProcessor * (priceVideoCard * 0.35);
- double priceRam = countRam * (priceVideoCard * 0.10);
- double finalSum = priceVideoCard + priceProcessors + priceRam;
- if(countVideoCard > countProcessor){
- finalSum = finalSum * 0.85; // finalSum - finalSum * 0.15
- }
- double diff = Math.abs(finalSum - budget);
- if(budget >= finalSum){
- 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