Silviyaa

03. Computer Room

Mar 21st, 2021
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E03ComputerRoom {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. String month = scanner.nextLine(); // "march", "april", "may", "june", "july", "august"
  8. int numberHours = Integer.parseInt(scanner.nextLine());
  9. int numberPerson = Integer.parseInt(scanner.nextLine());
  10. String tomeDay = scanner.nextLine(); // "day" или "night"
  11.  
  12. double price = 0;
  13. switch (month){
  14. case "march":
  15. case "april":
  16. case "may":
  17. case "day":
  18. if(numberPerson >= 4){
  19. price = 10.50 - 0.10;
  20. }
  21. if(numberHours >= 5){
  22. price = 10.50 - 0.50;
  23. }
  24. double totalPrice = (price * numberPerson) * numberHours;
  25. System.out.printf("Price per person for one hour: %.2f%n",price);
  26. System.out.printf("Total cost of the visit: %.2f",totalPrice);
  27.  
  28. break;
  29. }
  30. }
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment