Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class LabTest {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- String month=sc.nextLine();
- int overnights=Integer.parseInt(sc.nextLine());
- double appartmentRent=0;
- double appartmentDiscount=0;
- double studioRent=0;
- double studioDiscount=0;
- switch(month){
- case "May":
- case "October":
- studioRent=50.00;
- appartmentRent=65.00;
- if (overnights>14){
- studioDiscount=30;
- }else if (overnights>7){
- studioDiscount=5;
- }
- break;
- case "June":
- case "September":
- studioRent=75.20;
- appartmentRent=68.70;
- if (overnights>14){
- studioDiscount=20;
- }
- break;
- case "July":
- case "August":
- studioRent=76.00;
- appartmentRent=77.00;
- break;
- }
- if (overnights>14){
- appartmentDiscount=10;
- }
- double studioPrice=overnights*studioRent*(100-studioDiscount)/100;
- double appartmenttPrice=overnights*appartmentRent*(100-appartmentDiscount)/100;
- System.out.printf("Apartment: %.2f lv.%nStudio: %.2f lv.",appartmenttPrice,studioPrice);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment