Advertisement
psi_mmobile

Untitled

Aug 23rd, 2022
790
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.37 KB | None | 0 0
  1. public class MyClass {
  2.     public static void main(String args[]) {
  3.         java.util.Scanner scanner = new java.util.Scanner(System.in);
  4.        
  5.         int numberOfPeople = scanner.nextInt();
  6.         String typeOfVisitors = scanner.next();
  7.         String dayOfWeek = scanner.next();
  8.        
  9.         double basePriceStudent = 8.45;
  10.         double basePriceBusiness =  10.90;
  11.         double basePriceRegular = 15.00;
  12.        
  13.         double baseReduction = 0.00;
  14.        
  15.         double totalSum = 0.00;
  16.        
  17.         switch(dayOfWeek) {
  18.             case "Saturday" : basePriceRegular += 5; basePriceStudent +=1.35; basePriceBusiness+=4.7;break;
  19.             case "Sunday" : basePriceRegular += 7.5; basePriceStudent +=2.01; basePriceBusiness +=5.1;break;
  20.         }
  21.        
  22.         switch(typeOfVisitors) {
  23.             case "Students" : if(numberOfPeople >= 30) {baseReduction = 0.15;};totalSum = numberOfPeople * basePriceStudent;totalSum-=totalSum*baseReduction ;break;
  24.             case "Business" : if(numberOfPeople >= 100) {numberOfPeople-=10;};totalSum = numberOfPeople * basePriceBusiness;break;
  25.             case "Regular" : if(numberOfPeople >= 10 && numberOfPeople <= 20) {baseReduction = 0.05;};totalSum=numberOfPeople * basePriceRegular;totalSum=totalSum - totalSum*baseReduction;break;
  26.         }
  27.         System.out.printf("Total price: %.2f",totalSum);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement