Advertisement
Atidada

Untitled

May 3rd, 2020
682
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class Constance {
  5. public static void main(String[] args) {
  6. Scanner scan = new Scanner(System.in);
  7. String town = scan.nextLine();
  8. double sell = Double.parseDouble(scan.nextLine());
  9. double commision = 0;
  10. if ("Sofia".equals(town)) {
  11.  
  12. if (sell >= 0 && sell <= 500) {
  13. commision = sell * 0.05;
  14. } else if (sell > 500 && sell <= 1000) {
  15. commision = sell * 0.07;
  16. } else if (sell > 1000 && sell <= 10000) {
  17. commision = sell * 0.08;
  18. } else if (sell > 10000) {
  19. commision = sell * 0.12;
  20. }
  21. System.out.printf("%.02f", commision);
  22.  
  23. } else if ("Varna".equals(town)) {
  24. if (sell >= 0 && sell <= 500) {
  25. commision = sell * 0.045;
  26. } else if (sell > 500 && sell <= 1000) {
  27. commision = sell * 0.075;
  28. } else if (sell > 1000 && sell <= 10000) {
  29. commision = sell * 0.1;
  30. } else if (sell > 10000) {
  31. commision = sell * 0.13;
  32. }
  33. System.out.printf("%.02f", commision);
  34.  
  35. } else if ("Plovdiv".equals(town)) {
  36. if (sell >= 0 && sell <= 500) {
  37. commision = sell * 0.055;
  38. } else if (sell > 500 && sell <= 1000) {
  39. commision = sell * 0.08;
  40. } else if (sell > 1000 && sell <= 10000) {
  41. commision = sell * 0.12;
  42. } else if (sell > 10000) {
  43. commision = sell * 0.145;
  44. }
  45. System.out.printf("%.02f", commision);
  46.  
  47. }
  48. if ((!town.equals("Sofia") && !town.equals("Varna") && !town.equals("Plovdiv")) || sell < 0) {
  49. System.out.println("error");
  50. }
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement