Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyClass {
- public static void main(String args[]) {
- java.util.Scanner scanner = new java.util.Scanner(System.in);
- int numberOfPeople = scanner.nextInt();
- String typeOfVisitors = scanner.next();
- String dayOfWeek = scanner.next();
- double basePriceStudent = 8.45;
- double basePriceBusiness = 10.90;
- double basePriceRegular = 15.00;
- double baseReduction = 0.00;
- double totalSum = 0.00;
- switch(dayOfWeek) {
- case "Saturday" : basePriceRegular += 5; basePriceStudent +=1.35; basePriceBusiness+=4.7;break;
- case "Sunday" : basePriceRegular += 7.5; basePriceStudent +=2.01; basePriceBusiness +=5.1;break;
- }
- switch(typeOfVisitors) {
- case "Students" : if(numberOfPeople >= 30) {baseReduction = 0.15;};totalSum = numberOfPeople * basePriceStudent;totalSum-=totalSum*baseReduction ;break;
- case "Business" : if(numberOfPeople >= 100) {numberOfPeople-=10;};totalSum = numberOfPeople * basePriceBusiness;break;
- case "Regular" : if(numberOfPeople >= 10 && numberOfPeople <= 20) {baseReduction = 0.05;};totalSum=numberOfPeople * basePriceRegular;totalSum=totalSum - totalSum*baseReduction;break;
- }
- System.out.printf("Total price: %.2f",totalSum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement