Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class main {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- String season = scan.nextLine();
- int nights = Integer.parseInt(scan.nextLine());
- double apartment = 0;
- double studio = 0;
- double studioPrice = 0;
- double apartmentPrice = 0;
- double discountS = 0;
- double discountA = 0;
- if (season.equals("May") || season.equals("October")) {
- studioPrice = 50;
- apartmentPrice = 65;
- } else if (season.equals("June") || season.equals("September")) {
- studioPrice = 75.20;
- apartmentPrice = 68.70;
- } else if (season.equals("July") || season.equals("August")) {
- studioPrice = 76;
- apartmentPrice = 77;
- }
- switch(season){
- case "May":
- case "October":
- if (nights>7){
- discountS = 0.05 * studioPrice;
- }if (nights>14){
- discountS = 0.30 * studioPrice;
- }break;
- case "June":
- case"September":
- if (nights > 14){
- discountS = 0.20 * studioPrice;
- }break;
- default:break;
- }
- if(nights>14){
- discountA = 0.10 * apartmentPrice;
- }
- studioPrice-=discountS;
- apartmentPrice-=discountA;
- studio = studioPrice * nights;
- apartment = apartmentPrice *nights;
- System.out.printf("Apartment: %.2f lv.%n",apartment);
- System.out.printf("Studio: %.2f lv.",studio);
- }
- }
Add Comment
Please, Sign In to add comment