Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyClass {
- public static void main(String args[]) {
- java.util.Scanner scanner = new java.util.Scanner(System.in);
- String fruit = scanner.nextLine();
- String setSize = scanner.nextLine();
- int numberOfSets = scanner.nextInt();
- double watermelonPrice = 0.0;
- double mangoPrice = 0.0;
- double pineapplePrice = 0.0;
- double raspberryPrice = 0.0;
- if (setSize.equals("small")) {
- watermelonPrice = 56.00 * 2;
- mangoPrice = 36.66 * 2;
- pineapplePrice = 42.10 * 2;
- raspberryPrice = 20.00 * 2;
- } else {
- watermelonPrice = 28.70 * 5;
- mangoPrice = 19.60 * 5;
- pineapplePrice = 24.80 * 5;
- raspberryPrice = 15.20 * 5;
- }
- double totalPrice = 0.0;
- switch(fruit) {
- case "Watermelon" : totalPrice = watermelonPrice * numberOfSets;
- break;
- case "Mango" : totalPrice = mangoPrice * numberOfSets;
- break;
- case "Pineapple" : totalPrice = pineapplePrice * numberOfSets;
- break;
- case "Raspberry" : totalPrice = raspberryPrice * numberOfSets;
- break;
- }
- if (totalPrice >= 400 && totalPrice <= 1000) {
- totalPrice = totalPrice * 0.85;
- } else if (totalPrice < 400) {
- totalPrice = totalPrice;
- } else {
- totalPrice = totalPrice * 0.5;
- }
- System.out.printf("%.2f lv.",totalPrice);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement