Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- String cityName = scan.nextLine();
- String pack = scan.nextLine();
- String hasVIP = scan.nextLine();
- int days = Integer.parseInt(scan.nextLine());
- double singlePrice = 0.0;
- double percentageDiscount = 0;
- boolean isInvalid = false;
- switch (cityName) {
- case "Bansko":
- case "Borovets":
- if ("noEquipment".equals(pack)) {
- singlePrice = 80;
- percentageDiscount = 0.95;
- } else if ("withEquipment".equals(pack)){
- singlePrice = 100;
- percentageDiscount = 0.9;
- } else {
- isInvalid = true;
- }
- break;
- case "Varna":
- case "Burgas":
- if ("noBreakfast".equals(pack)) {
- singlePrice = 100;
- percentageDiscount = 0.93;
- } else if ("withBreakfast".equals(pack)){
- singlePrice = 130;
- percentageDiscount = 0.88;
- } else {
- isInvalid = true;
- }
- break;
- default:
- isInvalid = true;
- break;
- }
- if (days > 7) {
- days--;
- }
- if ("yes".equals(hasVIP)) {
- singlePrice = singlePrice * percentageDiscount;
- }
- if (days < 1) {
- System.out.println("Days must be positive number!");
- } else if (isInvalid) {
- System.out.println("Invalid input!");
- } else {
- double finalPrice = days * singlePrice;
- System.out.printf("The price is %.2flv! Have a nice time!", finalPrice);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement