Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class demo3 {
- public static void main(String[] agrs) {
- Scanner scanner = new Scanner(System.in);
- int days = Integer.parseInt(scanner.nextLine());
- String roomType = scanner.nextLine().toLowerCase();
- String feedback = scanner.nextLine().toLowerCase();
- double pricePerNight = 0;
- double discount = 0;
- if (roomType.equals("room for one person")) {
- pricePerNight = 18;
- } else if (roomType.equals("apartment")) {
- pricePerNight = 25;
- if (days < 10) {
- discount = 30;
- } else if (days < 15) {
- discount = 35;
- } else {
- discount = 50;
- }
- } else if (roomType.equals("president apartment")) {
- pricePerNight = 35;
- if (days < 10) {
- discount = 10;
- } else if (days < 15) {
- discount = 15;
- } else {
- discount = 20;
- }
- }
- double totalPrice = pricePerNight * (days - 1);
- double netPrice = totalPrice - (totalPrice * discount / 100);
- if (feedback.equals("positive")) {
- netPrice = netPrice * 1.25;
- } else if (feedback.equals("negative")) {
- netPrice *= 0.9;
- }
- System.out.printf("%.2f", netPrice);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement