Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- // Вход
- double peterBudget = Double.parseDouble(scan.nextLine());
- int videCardCount = Integer.parseInt(scan.nextLine());
- int processorCount = Integer.parseInt(scan.nextLine());
- int ramCount = Integer.parseInt(scan.nextLine());
- // Video Card
- int videoCardsTotalPrice = videCardCount * 250;
- // Processor
- double processorPrice = videoCardsTotalPrice * 0.35;
- double processorTotalPrice = processorCount * processorPrice;
- // Ram
- double ramPrice = videoCardsTotalPrice * 0.10;
- double ramTotalPrice = ramCount * ramPrice;
- double totalPrice = videoCardsTotalPrice + processorTotalPrice + ramTotalPrice;
- if (videCardCount > processorCount) {
- totalPrice = totalPrice * 0.85;
- }
- if (peterBudget >= totalPrice) {
- double moneyLeft = peterBudget - totalPrice;
- System.out.printf("You have %.2f leva left!", moneyLeft);
- } else {
- double moneyNeed = totalPrice - peterBudget;
- System.out.printf("Not enough money! You need %.2f leva more!", moneyNeed);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment