MladenKarachanov

Shoping

Jan 15th, 2024
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.12 KB | None | 0 0
  1. package ConditionalStatementsAdvancedLab;
  2.  
  3.  
  4.  
  5. import java.util.Scanner;
  6.  
  7.  
  8.  
  9.  
  10. public class Shoping {
  11.     public static void main(String[] args) {
  12.         Scanner scanner = new Scanner(System.in);
  13.         double budget = Double.parseDouble(scanner.nextLine());
  14.         int cart = Integer.parseInt(scanner.nextLine());
  15.         int processor = Integer.parseInt(scanner.nextLine());
  16.         int ram = Integer.parseInt(scanner.nextLine());
  17.         double discount = 0;
  18.         double finish = 0;
  19.         double total=0;
  20.         int sumCart = cart * 250;
  21.         double sumProcessor = processor *( 0.35*sumCart);
  22.         double sumRam = ram * (0.1*sumCart);
  23.         double sum = sumCart + sumProcessor + sumRam ;
  24.  
  25.  
  26.         if (cart > processor) {
  27.             sum = sum - (0.15*sum);
  28.  
  29.  
  30.         }
  31.         if (budget >= sum) {
  32.             double left=budget-sum;
  33.  
  34.  
  35.             System.out.printf("You have %.2f leva left!", left);
  36.         } else {
  37.            double result=sum-budget;
  38.  
  39.             System.out.printf("Not enough money! You need %.2f leva more!",result);
  40.  
  41.  
  42.         }
  43.  
  44.     }
  45. }
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
Add Comment
Please, Sign In to add comment