Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class demo {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String fruit = scanner.nextLine();
- String size = scanner.nextLine();
- int count = Integer.parseInt(scanner.nextLine());
- double price = 0;
- if(size.equals("small")){
- if(fruit.equals("Watermelon")){
- price = 2 * 56;
- }else if(fruit.equals("Mango")){
- price = 2 * 36.66;
- }else if(fruit.equals("Pineapple")){
- price = 2 * 42.1;
- }else if(fruit.equals("Raspberry")){
- price = 2 * 20;
- }
- }else{
- switch (fruit) {
- case "Watermelon":
- price = 5 * 28.7;
- break;
- case "Mango":
- price = 5 * 19.60;
- break;
- case "Pineapple":
- price = 5 * 24.80;
- break;
- case "Raspberry":
- price = 5 * 15.20;
- break;
- }
- }
- double totalPrice = count * price;
- if(totalPrice >= 400 && totalPrice <= 1000){
- totalPrice = totalPrice - (totalPrice * 0.15);
- }else if(totalPrice > 1000){
- totalPrice = totalPrice - (totalPrice * 0.50);
- }
- System.out.printf("%.2f lv.", totalPrice);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement