Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ConditionalStatementsAdvancedLab;
- import java.util.Scanner;
- public class Shoping {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double budget = Double.parseDouble(scanner.nextLine());
- int cart = Integer.parseInt(scanner.nextLine());
- int processor = Integer.parseInt(scanner.nextLine());
- int ram = Integer.parseInt(scanner.nextLine());
- double discount = 0;
- double finish = 0;
- double total=0;
- int sumCart = cart * 250;
- double sumProcessor = processor *( 0.35*sumCart);
- double sumRam = ram * (0.1*sumCart);
- double sum = sumCart + sumProcessor + sumRam ;
- if (cart > processor) {
- sum = sum - (0.15*sum);
- }
- if (budget >= sum) {
- double left=budget-sum;
- System.out.printf("You have %.2f leva left!", left);
- } else {
- double result=sum-budget;
- System.out.printf("Not enough money! You need %.2f leva more!",result);
- }
- }
- }
Add Comment
Please, Sign In to add comment