E
Esca Dude
Guest
This is what i got so far
import java.io.*;
import java.util.*;
import java.text.*;
public class rentcar
{
public static void main (String [] args)
throws java.io.IOException
{
RandomAccessFile raf = new RandomAccessFile("CarRental.dat", "rw");
String[] CarRental = {" Volkswagen", " Nissan", " Honda", " Toyota", " Suzuki", " Ford", " BMW", " Volvo", " Mazda", " Mitsubishi", " Navistar", " Chrysler", " Subaru", " Geely", " General Motors"};
//Ask user for which car he/she wants
String inputString;
int a;
//this sets up the basic input stream
InputStreamReader inputstr= new InputStreamReader(System.in);
//needed to use ReadLine
BufferedReader br1 = new BufferedReader(inputstr);
System.out.println("Menue");
System.out.println("Please choose one of the following Car Brands: " +"\n"+
"1. Volkswagen" +"\n"+
"2. Nissan" +"\n"+
"3. Honda" +"\n"+
"4. Toyota" +"\n"+
"5. Suzuki" +"\n"+
"6. Ford" +"\n"+
"7. BMW" +"\n"+
"8. Volvo" +"\n"+
"9. Mazda" +"\n"+
"10.Mitsubishi" +"\n"+
"11.Navistar " +"\n"+
"12.Chrysler" +"\n"+
"13.Subaru" +"\n"+
"14.Geely " +"\n"+
"15.General Motors");
inputString= br1.readLine();
a= Integer.parseInt(inputString);
switch (a)
{
case 1:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[0] );
break;
case 2:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[1] );
break;
case 3:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[2] );
break;
case 4:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[3] );
break;
case 5:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[4] );
break;
case 6:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[5] );
break;
case 7:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[6] );
break;
case 8:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[7] );
break;
case 9:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[8] );
break;
case 10:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[9] );
break;
case 11:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[10] );
break;
case 12:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[11] );
break;
case 13:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[12] );
break;
case 14:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[13] );
break;
case 15:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[14] );
break;
default:
System.out.println("Invalid Entry!");
}
raf.close();
}
}
BUT i was wondering how to add things to the Random Access File
import java.io.*;
import java.util.*;
import java.text.*;
public class rentcar
{
public static void main (String [] args)
throws java.io.IOException
{
RandomAccessFile raf = new RandomAccessFile("CarRental.dat", "rw");
String[] CarRental = {" Volkswagen", " Nissan", " Honda", " Toyota", " Suzuki", " Ford", " BMW", " Volvo", " Mazda", " Mitsubishi", " Navistar", " Chrysler", " Subaru", " Geely", " General Motors"};
//Ask user for which car he/she wants
String inputString;
int a;
//this sets up the basic input stream
InputStreamReader inputstr= new InputStreamReader(System.in);
//needed to use ReadLine
BufferedReader br1 = new BufferedReader(inputstr);
System.out.println("Menue");
System.out.println("Please choose one of the following Car Brands: " +"\n"+
"1. Volkswagen" +"\n"+
"2. Nissan" +"\n"+
"3. Honda" +"\n"+
"4. Toyota" +"\n"+
"5. Suzuki" +"\n"+
"6. Ford" +"\n"+
"7. BMW" +"\n"+
"8. Volvo" +"\n"+
"9. Mazda" +"\n"+
"10.Mitsubishi" +"\n"+
"11.Navistar " +"\n"+
"12.Chrysler" +"\n"+
"13.Subaru" +"\n"+
"14.Geely " +"\n"+
"15.General Motors");
inputString= br1.readLine();
a= Integer.parseInt(inputString);
switch (a)
{
case 1:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[0] );
break;
case 2:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[1] );
break;
case 3:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[2] );
break;
case 4:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[3] );
break;
case 5:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[4] );
break;
case 6:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[5] );
break;
case 7:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[6] );
break;
case 8:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[7] );
break;
case 9:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[8] );
break;
case 10:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[9] );
break;
case 11:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[10] );
break;
case 12:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[11] );
break;
case 13:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[12] );
break;
case 14:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[13] );
break;
case 15:System.out.println("The Type Of Car You Have Choosen Is" + CarRental[14] );
break;
default:
System.out.println("Invalid Entry!");
}
raf.close();
}
}
BUT i was wondering how to add things to the Random Access File