Hi there, i'm having trouble with creating the Pseudocode for my program, the program took me ages to complete with alot of help, i sort of understand what needs to be done, but could someone start me off as i'm unsure of how to begin:-
import java.io.*;
import java.util.*;
public class Motors
{
// instantiate a console Scanner
private static Scanner console = new Scanner(System.in);
public static void main ( String [] args ) throws IOException
{
// instantiate a new Garage
Garage theGarage = new Garage();
// variables used for user input
String aManufacturer;
String aModel;
int aYear;
String aRegNo;
int aPrice;
int aMileage;
int i;
do // menu loop
{
// call the processMenu method - evaluate return value
switch( processMenu())
{
case 1: // Print Stock to File - Display to console
theGarage.printSaveCarReport();
break;
case 2: // Save car details back to the car details.txt File
theGarage.saveCarDetails();
System.out.println("The car details.txt file has been updated.");
break;
case 3: // Add Car
if( theGarage.garageFull())
{
System.err.println("Unable to add Car. Array is full.");
break;
}
// get registration number from user
System.out.print("For add, enter car registration number: ");
aRegNo = console.nextLine();
// loop thru cars
for( i = 0; i < theGarage.getCarCount(); i++)
// if inputted registration number matches an existing car
if( theGarage.getCarDetail(i).getRegNo().toUpperCase().equals(aRegNo.toUpperCase()) )
{
// display error message and break out of loop
System.out.println("Unable to add that car. It already exists.");
break;
}
// if unable to add car
if( i < theGarage.getCarCount())
break;
// get remainder of car values from user
System.out.print("For add, enter car manufacturer: ");
aManufacturer = console.nextLine();
System.out.print("For add, enter car model: ");
aModel = console.nextLine();
System.out.print("For add, enter car year: ");
aYear = Integer.parseInt(console.nextLine());
System.out.print("For add, enter car price: ");
aPrice = Integer.parseInt(console.nextLine());
System.out.print("For add, enter car mileage: ");
aMileage = Integer.parseInt(console.nextLine());
// call the Garage addCar method passing inputted values
theGarage.addCar(aManufacturer, aModel, aRegNo, aYear, aPrice, aMileage);
System.out.println("Car has been added.");
break;
case 4: // Sell car
// if no cars exist
if( theGarage.getCarCount() == 0)
{
System.err.println("Sorry, no cars available to sell.");
break;
}
// get registration number from user
System.out.print("For sell, enter car registration number: ");
aRegNo = console.nextLine();
// check to see if it exists
for( i = 0; i < theGarage.getCarCount(); i++)
// if it exists
if( theGarage.getCarDetail(i).getRegNo().toUpperCase().equals(aRegNo.toUpperCase()) )
{
// call the Garage sellCar method passing inputted registration number
theGarage.sellCar(aRegNo);
System.out.println("Car is sold.");
break;
}
// if no match was found
if( i == theGarage.getCarCount())
System.out.println("Unable to sell car. Not in listing.");
break;
case 5: // Amend Price
// if no cars
if( theGarage.getCarCount() == 0)
{
System.err.println("Sorry, no cars available to amend.");
break;
}
// get registration number from user
System.out.print("For amend, enter car registration number: ");
aRegNo = console.nextLine();
// try and find a matching car
for( i = 0; i < theGarage.getCarCount(); i++)
// if a match
if( theGarage.getCarDetail(i).getRegNo().toUpperCase().equals(aRegNo.toUpperCase()) )
{
// get new price from user
System.out.print("Enter new price: ");
aPrice = Integer.parseInt(console.nextLine());
// call the Car setPrice method passing inputted price
theGarage.getCarDetail(i).setPrice(aPrice);
System.out.println("Car price has been amended.");
break; // break out for loop
}
// if no match was found
if( i == theGarage.getCarCount())
System.out.println("Unable to amend car price. Not in listing.");
break;
case 6: // Find car details
// if no car exists
if( theGarage.getCarCount() == 0)
{
System.err.println("Sorry, no cars available to find.");
break;
}
// get registration number from user
System.out.print("For find, enter car registration number: ");
aRegNo = console.nextLine();
// try and find matching car
for( i = 0; i < theGarage.getCarCount(); i++)
// if a match
if( theGarage.getCarDetail(i).getRegNo().toUpperCase().equals(aRegNo.toUpperCase()) )
{
// display this car's details
System.out.println(theGarage.getCarDetail(i));
break;
}
// if no match was found
if( i == theGarage.getCarCount())
System.out.println("Unable to find car. Not in listing.");
break;
case 7: // Exit
System.exit(1); // exit program
break;
}
} while(true);
}//main
Any help would be much appreciated