Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SkiTrip {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int days = Integer.parseInt(scanner.nextLine());
- String rooms = scanner.nextLine();
- String grade = scanner.nextLine();
- double nights = days - 1;
- double price = 0;
- switch (rooms){
- case "room for one person":
- price = nights * 18.00;
- break;
- case "apartment":
- price = nights * 25.00;
- if (price < 10){
- price *= 0.7;
- }else if (price <= 15){
- price *= 0.65;
- }else if (price > 15){
- price *= 0.5;
- }
- break;
- case "president apartment":
- price = nights * 35.00;
- if (days < 10){
- price *= 0.9;
- }else if (days <= 15){
- price *= 0.85;
- }else if (days > 15){
- price *= 0.8;
- }
- break;
- }
- if ("positive".equalsIgnoreCase(grade)){
- price = price + (price * 0.25);
- }else {
- price = price - (price * 0.1);
- }
- System.out.println(String.format("%.2f", price));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement