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 room = scanner.nextLine();
- String feedback = scanner.nextLine();
- double discountedCost = 0;
- double finalCost = 0;
- int nights = days - 1;
- switch (room) {
- case "room for one person":
- discountedCost = nights * 18;
- break;
- case "apartment":
- if (nights < 10) {
- discountedCost = nights * 25 * 0.70;
- }
- else if (nights >= 10 && nights <= 15 ) {
- discountedCost = nights * 25 * 0.65;
- }
- else if (days > 15) {
- discountedCost = nights * 25 * 0.50;
- }
- break;
- case "president apartment":
- if (nights < 10) {
- discountedCost = nights * 35 * 0.90;
- }
- else if (nights >= 10 && nights <= 15 ) {
- discountedCost = nights * 35 * 0.85;
- }
- else if (days > 15) {
- discountedCost = nights * 35 * 0.80;
- }
- break;
- }
- // System.out.println(nights);
- // System.out.println(discountedCost);
- if ("positive".equals(feedback)) {
- finalCost = discountedCost * 1.25;
- }
- else if ("negative".equals(feedback)) {
- finalCost = discountedCost * 0.90;
- }
- System.out.printf("%.2f", finalCost);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment