Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 gpu = Integer.parseInt(scanner.nextLine());
- int cpu = Integer.parseInt(scanner.nextLine());
- int ram = Integer.parseInt(scanner.nextLine());
- int gpuPrice = gpu * 250;
- double cpuPrice = cpu * gpuPrice * 0.35;
- double ramPrice = ram * gpuPrice * 0.10;
- double totalAmount = gpuPrice + cpuPrice + ramPrice;
- if (gpu > cpu) {
- totalAmount *= 0.85;
- }
- if (budget >= totalAmount) {
- System.out.printf("You have %.2f leva left!", budget - totalAmount);
- } else {
- System.out.printf("Not enough money! You need %.2f leva more!", totalAmount - budget);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement