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;
- int multiplier = 0;
- if (setSize.equals("small")) {
- watermelonPrice = 56.00;
- mangoPrice = 36.66;
- pineapplePrice = 42.10;
- raspberryPrice = 20.00;
- multiplier = 2;
- } else {
- watermelonPrice = 28.70;
- mangoPrice = 19.60;
- pineapplePrice = 24.80;
- raspberryPrice = 15.20;
- multiplier = 5;
- }
- double totalPrice = 0.0;
- switch(fruit) {
- case "Watermelon" : totalPrice = watermelonPrice * numberOfSets * multiplier;
- if (totalPrice >= 400 && totalPrice <= 1000) {
- totalPrice = totalPrice * 0.85;
- } else if (totalPrice < 400) {
- totalPrice = totalPrice;
- } else {
- totalPrice = totalPrice * 0.5;
- } break;
- case "Mango" : totalPrice = mangoPrice * numberOfSets * multiplier;
- if (totalPrice >= 400 && totalPrice <= 1000) {
- totalPrice = totalPrice * 0.85;
- } else if (totalPrice < 400) {
- totalPrice = totalPrice;
- } else {
- totalPrice = totalPrice * 0.5;
- } break;
- case "Pineapple" : totalPrice = pineapplePrice * numberOfSets * multiplier;
- if (totalPrice >= 400 && totalPrice <= 1000) {
- totalPrice = totalPrice * 0.85;
- } else if (totalPrice < 400) {
- totalPrice = totalPrice;
- } else {
- totalPrice = totalPrice * 0.5;
- } break;
- case "Raspberry" : totalPrice = raspberryPrice * numberOfSets * multiplier;
- if (totalPrice >= 400 && totalPrice <= 1000) {
- totalPrice = totalPrice * 0.85;
- } else if (totalPrice < 400) {
- totalPrice = totalPrice;
- } else {
- totalPrice = totalPrice * 0.5;
- } break;
- }
- System.out.printf("%.2f lv.",totalPrice);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement