fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8.  
  9. class Automobile {
  10.  
  11. private String make;
  12. private String model;
  13. private String color;
  14. private int year;
  15. private int mileage;
  16.  
  17. public String getMake() {
  18. return make;
  19. }
  20. public void setMake(String make) {
  21. this.make = make;
  22. }
  23. public String getModel() {
  24. return model;
  25. }
  26. public void setModel(String model) {
  27. this.model = model;
  28. }
  29. public String getColor() {
  30. return color;
  31. }
  32. public void setColor(String color) {
  33. this.color = color;
  34. }
  35. public int getYear() {
  36. return year;
  37. }
  38. public void setYear(int year) {
  39. this.year = year;
  40. }
  41. public int getMileage() {
  42. return mileage;
  43. }
  44. public void setMileage(int mileage) {
  45. this.mileage = mileage;
  46. }
  47.  
  48. public Automobile(String make, String model, String Color, int year, int mileage) {
  49. this.make = make;
  50. this.model = model;
  51. this.color = color;
  52. this.year = year;
  53. this.mileage = mileage;
  54. }
  55. }
  56.  
  57. //import java.util.*;
  58.  
  59. class automobileInventory {
  60.  
  61. private static final int INVENTORY_SIZE = 15;
  62. private static Automobile[] automobiles = new Automobile[INVENTORY_SIZE];
  63.  
  64. private static Scanner scnr = new Scanner(System.in);
  65.  
  66. //static {
  67. // automobiles = new Automobile[INVENTORY_SIZE];
  68. //}
  69.  
  70. public static void automobileInventory() {
  71. String quit;
  72. int i = 0;
  73. do {
  74. // System.out.println("Car Model: (Enter Quit to exit data entry) ");
  75. // String model = scnr.nextLine();
  76.  
  77. // System.out.println("Car Make: ");
  78. // String make = scnr.nextLine();
  79.  
  80. // System.out.println("Car Color: ");
  81. // String color = scnr.nextLine();
  82.  
  83. // System.out.println("Car Year: ");
  84. // int year = scnr.nextInt();
  85.  
  86. // System.out.println("Car Mileage: ");
  87. // int mileage = scnr.nextInt();
  88.  
  89. automobiles[i] = new Automobile("abc", "xyz", "black", 2018, 2000);
  90. i++;
  91.  
  92. System.out.println("Do you want to quit [Yes/No]? ");
  93. quit = scnr.nextLine();
  94. }
  95. while (!quit.equalsIgnoreCase("yes"));
  96. }
  97.  
  98. public static void main(String[] args) {
  99. automobileInventory();
  100. }
  101. }
Success #stdin #stdout 0.12s 29592KB
stdin
no
yes
stdout
Do you want to quit [Yes/No]? 
Do you want to quit [Yes/No]?