Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class P03_HotelRoom {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- String month = scan.nextLine();
- int days = Integer.parseInt(scan.nextLine());
- double studioPrice = 0, apartmentPrice = 0;
- switch (month) {
- case "May":
- case "October":
- if(days > 7 && days <= 14){
- studioPrice = 50 * 0.95;
- } else if (days > 14){
- studioPrice = 50 * 0.7;
- } else {
- studioPrice = 50;
- }
- apartmentPrice = 65;
- break;
- case "June":
- case "September":
- if(days > 14){
- studioPrice = 75.20 * 0.8;
- } else {
- studioPrice = 75.20;
- }
- apartmentPrice = 68.70;
- break;
- default:
- studioPrice = 76;
- apartmentPrice = 77;
- break;
- }
- if(days > 14){
- apartmentPrice *= 0.9;
- }
- double totalPriceApartment = days * apartmentPrice;
- double totalPriceStudio = days * studioPrice;
- System.out.printf("Apartment: %.2f lv.\n", totalPriceApartment);
- System.out.printf("Studio: %.2f lv.", totalPriceStudio);
- }
- }
Add Comment
Please, Sign In to add comment