Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

THIS IS NOT WORKING IDK WHY PLEASE HELP AND SHOW A PICTURE import java.util.ArrayList; import java.util.Scanner; public class Automobile { private String make; private String

THIS IS NOT WORKING IDK WHY PLEASE HELP AND SHOW A PICTURE

import java.util.ArrayList; import java.util.Scanner; public class Automobile { private String make; private String model; private String color; private int year; private int mileage; private ArrayList vehicleList; public Automobile() { vehicleList = new ArrayList(); } public Automobile(String make, String model, String color, int year,int mileage) { this.make = make; this.model = model; this.color = color; this.year = year; this.mileage = mileage; } public String getMake() { return make; } public String getModel() { return model; } public String getColor() { return color; } public int getYear() { return year; } public int getMileage() { return mileage; } public void setMake(String make) { this.make = make; } public void setModel(String model) { this.model = model; } public void setColor(String color) { this.color = color; } public void setYear(int year) { this.year = year; } public void setMileage(int mileage) { this.mileage = mileage; } public void addVehicle(Automobile vehicle) { vehicleList.add(vehicle); } public void removeVehicle(String make, String model, String color, int year, int mileage) { for (int i=0;i

public void Display() { BufferedWriter bw = null; try { // creating File Writer to write text file FileWriter fw = new FileWriter("automobile_output.txt"); // creating Buffered Writer to write text file bw = new BufferedWriter(fw); System.out.println(" Vehicles Information: "); for (int i=0;i

public static void main(String[] args) { Automobile automobile = new Automobile(); Scanner userInput = new Scanner(System.in); while(true) { System.out.println(" Select Below option:"); System.out.println("Enter 1 for Add Vehicle"); System.out.println("Enter 2 for Update Vehicle"); System.out.println("Enter 3 for Remove Vehicle"); System.out.println("Enter 4 for Display Vehicles"); System.out.println("Enter 5 for Exit"); System.out.print("Chose option: "); int option = userInput.nextInt(); userInput.nextLine(); if (option == 1) { System.out.println(" Enter Vehicle Information to Add:"); System.out.print("Enter Maker: "); String maker = userInput.nextLine(); System.out.print("Enter Model: "); String model = userInput.nextLine(); System.out.print("Enter Color: "); String color = userInput.nextLine(); System.out.print("Enter Manufacturing Year: "); int year = userInput.nextInt(); userInput.nextLine(); System.out.print("Enter Mileage: "); int mileage = userInput.nextInt(); userInput.nextLine(); Automobile vehicle = new Automobile(maker, model, color, year, mileage); automobile.addVehicle(vehicle); } else if (option == 2) { System.out.println(" Enter Old Vehicle Information to Update:"); System.out.print("Enter Maker: "); String makerOld = userInput.nextLine(); System.out.print("Enter Model: "); String modelOld = userInput.nextLine(); System.out.print("Enter Color: "); String colorOld = userInput.nextLine(); System.out.print("Enter Manufacturing Year: "); int yearOld = userInput.nextInt(); userInput.nextLine(); System.out.print("Enter Mileage: "); int mileageOld = userInput.nextInt(); userInput.nextLine(); System.out.println(" Enter New Vehicle Information to Update:"); System.out.print("Enter Maker: "); String makerNew = userInput.nextLine(); System.out.print("Enter Model: "); String modelNew = userInput.nextLine(); System.out.print("Enter Color: "); String colorNew = userInput.nextLine(); System.out.print("Enter Manufacturing Year: "); int yearNew = userInput.nextInt(); userInput.nextLine(); System.out.print("Enter Mileage: "); int mileageNew = userInput.nextInt(); userInput.nextLine(); automobile.updateVehicle(makerOld, modelOld, colorOld, yearOld, mileageOld, makerNew, modelNew, colorNew, yearNew, mileageNew); } else if (option == 3) { System.out.println(" Enter Vehicle Information to Remove:"); System.out.print("Enter Maker: "); String maker = userInput.nextLine(); System.out.print("Enter Model: "); String model = userInput.nextLine(); System.out.print("Enter Color: "); String color = userInput.nextLine(); System.out.print("Enter Manufacturing Year: "); int year = userInput.nextInt(); userInput.nextLine(); System.out.print("Enter Mileage: "); int mileage = userInput.nextInt(); userInput.nextLine(); automobile.removeVehicle(maker, model, color, year, mileage); } else if (option == 4) { automobile.Display(); } else { System.out.println("Exit!"); break; } } userInput.close(); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Genetic Databases

Authors: Martin J. Bishop

1st Edition

0121016250, 978-0121016258

More Books

Students also viewed these Databases questions

Question

cs - 2 3 7 airplane object

Answered: 1 week ago