Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.DecimalFormat;
- import java.util.Scanner;
- public class zad4 {
- public static void main(String[] args) {
- Scanner console = new Scanner(System.in);
- DecimalFormat df = new DecimalFormat("0.00");
- String month = console.nextLine();
- int nights = Integer.parseInt(console.nextLine());
- double studioPrice = 0;
- double doublePrice = 0;
- double suitePrice = 0;
- int studioPriceHelp = 0;
- switch (month) {
- case "May":
- case "October":
- studioPrice = 50;
- doublePrice = 65;
- suitePrice = 75;
- break;
- case "June":
- case "September":
- studioPrice = 60;
- doublePrice = 72;
- suitePrice = 82;
- break;
- case "July":
- case "August":
- case "December":
- studioPrice = 68;
- doublePrice = 77;
- suitePrice = 89;
- break;
- }
- doublePrice *= nights;
- suitePrice *= nights;
- if (nights > 7 && (month.equals("May") || month.equals("October"))) {
- studioPrice *= 0.95;
- } else if (nights > 14 && (month.equals("June") || month.equals("September"))) {
- doublePrice *= 0.90;
- } else if (nights > 14 && (month.equals("July") || month.equals("August") || month.equals("December"))) {
- suitePrice *= 0.85;
- }
- if (nights > 7 && (month.equals("September") || month.equals("October")))
- {
- studioPrice *= (nights - 1);
- }
- else
- {
- studioPrice *= nights;
- }
- String line = ("Studio: " + df.format(studioPrice) + " lv.\n")
- + ("Double: "+ df.format(doublePrice) + " lv.\n")
- + ("Suite: " + df.format(suitePrice)) + " lv.";
- System.out.println(line);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment