Advertisement
desislava_topuzakova

Untitled

Sep 28th, 2022
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. package ConditionalStatementsAdvanced.AdditionalExercises;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class TruckDriver {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. String season = scanner.nextLine();
  10. double kmMonth = Double.parseDouble(scanner.nextLine());
  11. double profitMonth = 0;
  12. double totalProfit = 0;
  13.  
  14. switch (season) {
  15. case "Spring":
  16. case "Autumn":
  17. if (kmMonth <= 5000) {
  18. profitMonth = 0.75 * kmMonth;
  19. } else if (kmMonth > 5000 && kmMonth <= 10000) {
  20. profitMonth = 0.95 * kmMonth;
  21. } else if (kmMonth > 10000 && kmMonth <= 200000) {
  22. profitMonth = 1.45 * kmMonth;
  23. }
  24. break;
  25. case "Summer":
  26. if (kmMonth <= 5000) {
  27. profitMonth = 0.90 * kmMonth;
  28. } else if (kmMonth > 5000 && kmMonth <= 10000) {
  29. profitMonth = 1.10 * kmMonth;
  30. } else if (kmMonth > 10000 && kmMonth <= 200000) {
  31. profitMonth = 1.45 * kmMonth;
  32. }
  33. break;
  34. case "Winter":
  35. if (kmMonth <= 5000) {
  36. profitMonth = 1.05 * kmMonth;
  37. } else if (kmMonth > 5000 && kmMonth <= 10000) {
  38. profitMonth = 1.25 * kmMonth;
  39. } else if (kmMonth > 10000 && kmMonth <= 200000) {
  40. profitMonth = 1.45 * kmMonth;
  41. }
  42. break;
  43. }
  44.  
  45. totalProfit = profitMonth * 4;
  46. totalProfit *= 0.9;
  47.  
  48. System.out.printf("%.2f", totalProfitAfterTax);
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement