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 room = scanner.nextLine();
- String rating = scanner.nextLine();
- double priceOne = 18.00;
- double priceTwo = 25.00;
- double priceThree = 35.00;
- double price = 0.00;
- double nights = days - 1;
- if (room.equals("room for one person")) {
- if (nights < 10) {
- price = priceOne * nights;
- } else if (nights <= 15) {
- price = priceOne * nights;
- } else {
- price = priceOne * nights;
- }
- } else if (room.equals("apartment")) {
- if (nights < 10) {
- price = priceTwo * nights * 0.70;
- } else if (nights <= 15) {
- price = priceTwo * nights * 0.65;
- } else {
- price = priceTwo * nights * 0.50;
- }
- } else if (room.equals("president apartment")) {
- if (nights < 10) {
- price = priceThree * nights * 0.90;
- } else if (nights <= 15) {
- price = priceThree * nights * 0.85;
- } else {
- price = priceThree * nights * 0.80;
- }
- }
- if (rating.equals("positive")) {
- price = price + (0.25 * price);
- } else if (rating.equals("negative")) {
- price = price - (0.10 * price);
- }
- System.out.printf("%.2f", price);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement