Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.34 KB | None | 0 0
  1. public class Trailers {
  2. public static Scanner scanner = new Scanner(System.in);
  3. public static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  4. public static String question;
  5. public static int smallTrailer = 5;
  6. public static String costumerName;
  7. public static String[] namesSmallTrailer = {"", "", "", "", ""};
  8. public static int i = 0;
  9.  
  10.  
  11. public static void smallTrailerAvaible() {
  12. System.out.println("there are " + smallTrailer + " small trailers avaible");
  13. }
  14.  
  15. static void costumersNames() throws IOException {
  16.  
  17. int number = 1;
  18. for (int i = 0; i < 5; i++) {
  19. System.out.println("Small trailer " + number + " " + namesSmallTrailer[i]);
  20. number++;
  21. }
  22.  
  23. }
  24.  
  25.  
  26. public static void smallTrailers() throws IOException {
  27. System.out.println("Name of costumer");
  28.  
  29.  
  30. namesSmallTrailer[i] = reader.readLine();
  31. if (namesSmallTrailer.equals("")) {
  32. System.out.println("Please enter name");
  33. }
  34.  
  35.  
  36.  
  37.  
  38. int weight = 750;
  39. System.out.println("What is the weight of the load (in kg)?");
  40. int weightSmall = scanner.nextInt();
  41. int optimalWeight = weightSmall - weight;
  42. if(weightSmall >weight)
  43.  
  44. {
  45. System.out.println("Warning! The maximum load (750 kg) is exceeded by " + optimalWeight + " kg!");
  46. }
  47. System.out.println("Are you sure y/n");
  48. question =scanner.next();
  49. if(question.equals("y"))
  50.  
  51. {
  52.  
  53. if (smallTrailer >= 5) {
  54. System.out.println("there are no trailers avaible");
  55. } else {
  56. smallTrailer = smallTrailer - 1;
  57. i++;
  58.  
  59.  
  60. }
  61.  
  62. }
  63. if(question.equals("n"))
  64.  
  65. {
  66.  
  67. namesSmallTrailer[i] = "";
  68. }
  69.  
  70. }
  71.  
  72. static void largeTrailers() {
  73.  
  74. }
  75.  
  76. static void Overview() throws IOException {
  77. costumersNames();
  78. smallTrailerAvaible();
  79.  
  80.  
  81. }
  82.  
  83. static void exitMenu() {
  84. System.exit(0);
  85.  
  86. }
  87.  
  88. public void menu() throws IOException {
  89. char quit = 'n';
  90. String input;
  91. int choise = 0;
  92. Scanner scanner = new Scanner(System.in);
  93. boolean a = true;
  94.  
  95.  
  96. while (a) {
  97. System.out.println("******************************************");
  98. System.out.println("* Trailer rental");
  99. System.out.println("******************************************");
  100. System.out.println("* 1) Rent small trailer 1");// 5
  101. System.out.println("* 2) Rent large trailer"); // 3
  102. System.out.println("* 3) Overview"); // арендованые
  103. System.out.println("* 9) Exit");
  104. System.out.println("******************************************");
  105. System.out.println(" Select an option:");
  106.  
  107. choise = scanner.nextInt();
  108. switch (choise) {
  109. case 1:
  110. smallTrailers();
  111. break;
  112. case 2:
  113. largeTrailers();
  114. break;
  115. case 3:
  116. Overview();
  117. break;
  118. case 9:
  119. exitMenu();
  120. default:
  121. System.out.println("Choose between 1,2 or 9");
  122.  
  123. }
  124. }
  125. }
  126.  
  127. public static void main(String[] args) throws IOException {
  128. new Trailers().menu();
  129.  
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement