aneliabogeva

Trade commission

Nov 10th, 2020
51
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class BiggerNumber {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. String town = scanner.nextLine();
  7. Double volume = Double.parseDouble(scanner.nextLine());
  8. double commission;
  9.  
  10. switch (town) {
  11. case "Sofia":
  12. if(volume>=0 && volume <=500){
  13. commission = volume * 0.05;
  14. System.out.printf("%.2f", commission);
  15. } else if(volume > 500 && volume <= 1000){
  16. commission = volume * 0.07;
  17. System.out.printf("%.2f", commission);
  18. }else if(volume > 1000 && volume <= 10000){
  19. commission = volume * 0.08;
  20. System.out.printf("%.2f", commission);
  21. }else if(volume > 10000) {
  22. commission = volume * 0.12;
  23. System.out.printf("%.2f", commission);
  24. }else{
  25. System.out.println("error");
  26. }
  27. break;
  28.  
  29. case "Plovdiv":
  30. if(volume>=0 && volume <=500){
  31. commission = volume * 0.055;
  32. System.out.printf("%.2f", commission);
  33. } else if(volume > 500 && volume <= 1000){
  34. commission = volume * 0.08;
  35. System.out.printf("%.2f", commission);
  36. }else if(volume > 1000 && volume <= 10000){
  37. commission = volume * 0.12;
  38. System.out.printf("%.2f", commission);
  39. }else if(volume > 10000) {
  40. commission = volume * 0.145;
  41. System.out.printf("%.2f", commission);
  42. }else{
  43. System.out.println("error");
  44. }
  45. break;
  46. case "Varna":
  47. if(volume>=0 && volume <=500){
  48. commission = volume * 0.045;
  49. System.out.printf("%.2f", commission);
  50. } else if(volume > 500 && volume <= 1000){
  51. commission = volume * 0.075;
  52. System.out.printf("%.2f", commission);
  53. }else if(volume > 1000 && volume <= 10000){
  54. commission = volume * 0.10;
  55. System.out.printf("%.2f", commission);
  56. }else if(volume > 10000) {
  57. commission = volume * 0.13;
  58. System.out.printf("%.2f", commission);
  59. }else{
  60. System.out.println("error");
  61. }
  62.  
  63. break;
  64.  
  65.  
  66. default:
  67. System.out.println("error");
  68. break;
  69. }
  70. }
  71. }
  72.  
RAW Paste Data