Untitled

 avatar
unknown
plain_text
13 days ago
985 B
10
Indexable
import java.util.Scanner;

public class Shopping {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double budget = Double.parseDouble(sc.nextLine());

        int gpuCount = Integer.parseInt(sc.nextLine());
        int cpuCount = Integer.parseInt(sc.nextLine());
        int ramCount = Integer.parseInt(sc.nextLine());

        double gpuAmount = gpuCount * 250;
        double cpuAmount = 0.35 * gpuAmount * cpuCount;
        double ramAmount = 0.1 * gpuAmount * ramCount;
        double totalSpend = gpuAmount + cpuAmount + ramAmount;

        if (gpuCount > cpuCount) {
            totalSpend = totalSpend - 0.15 * totalSpend;
        }

        if (totalSpend <= budget) {
            System.out.printf("You have %.2f leva left!", Math.abs(budget - totalSpend));
        } else {
            System.out.printf("Not enough money! You need %.2f leva more!", Math.abs(budget - totalSpend));
        }
    }
}
Leave a Comment