Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String year = scanner.nextLine();
- String type = scanner.nextLine();
- String dessert = scanner.nextLine();
- int months = Integer.parseInt(scanner.nextLine());
- double price = 0.0;
- double totalPrice = 0.0;
- switch (year) {
- case "one":
- if (type.equals("Small" )) {
- price = 9.98;
- } else if (type.equals("Middle" )) {
- price = 18.99;
- } else if (type.equals("Large" )) {
- price = 25.98;
- } else if (type.equals("ExtraLarge" )) {
- price = 35.99;
- }
- break;
- case "two":
- if (type.equals("Small" )) {
- price = 8.58;
- } else if (type.equals("Middle" )) {
- price = 17.09;
- } else if (type.equals("Large" )) {
- price = 23.59;
- } else if (type.equals("ExtraLarge" )) {
- price = 31.79;
- }
- break;
- }
- double dessertPrice = 0.0;
- if (dessert.equals("yes" )) {
- if (price <= 10) {
- dessertPrice = 5.5;
- } else if (price <= 30) {
- dessertPrice = 4.35;
- } else if (price > 30) {
- dessertPrice = 3.85;
- }
- }
- totalPrice = (price + dessertPrice) * months;
- if (year.equals("two" )) {
- totalPrice = totalPrice * 0.375;
- }
- System.out.printf("%.2f lv.", totalPrice );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement