Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

My assignment is: 1. Declare a Vector to hold the names of courses offered in th

ID: 3634850 • Letter: M

Question

My assignment is:
1. Declare a Vector to hold the names of courses offered in theCSC department for a given semester. Example, "CSC160 Java","CSC126 Game Design", "CSC116 Logic and Design", etc.

2. Let the user do one of the following options:

1. Print back the list of courses offeredalong with the number of courses offered

(number of elements inVector).

2. Lookup some courses. The user can enter something like Javaand the program will print back any course that has the word Javain it (if any). You might be using some of the String methods suchas the ones used in table 10-3 pg.622.

3. Add a course. The user can add a new course name to the endof the list.

4. Remove a course from the list.

Here is my code:
import java.io.*;
import java.util.*;
import java.lang.*;

public class ACCCourses{

public static Vector<String> courses= newVector<String>();


public static void main(String args[]) {


int input = 0;
do{

System.out.println(" type 1 to print the list of courses type 2 to lookup some course " +
" type 3 to add a course to the end of the list type 4 to remove a course from the list type 5 to exit the program");
//System.out.print("Enter the number for the opearation you want todo: ");
try{
input = Integer.parseInt (newBufferedReader(new InputStreamReader(System.in)).readLine());
}
catch (Exception e){
e.printStackTrace();
}
//input = Integer.parseInt (new BufferedReader(newInputStreamReader(System.in)).readLine());
System.out.println();
if(input ==1)
{
int length = courses.size();
int c=0;
System.out.println("Printing the courses in the list");
while(c<length)
{
System.out.println(courses.elementAt(c));
c++;
}
System.out.println();

} //end of 1


if(input ==2)
{
String cor="";
System.out.print("Enter the word you want to look in the list:");
try{
cor = (new BufferedReader(newInputStreamReader(System.in)).readLine());
}
catch (Exception e){
e.printStackTrace();
}
System.out.println();
System.out.println();

int length = courses.size();
int c=0;
System.out.println("Looking for the courses in thelist");
while(c<length)
{
String course = courses.elementAt(c);
int j = course.indexOf(cor);
if( j != -1)
System.out.println(course);

c++;
}
System.out.println();
} ///end of 2

if(input ==3)
{
System.out.print("Enter the name of the course: ");
String cor="";
try{
cor = (new BufferedReader(newInputStreamReader(System.in)).readLine());
courses.add(cor);
}
catch (Exception e){
e.printStackTrace();
}
System.out.println();
System.out.println();

} //end of 3

if(input ==4)
{
System.out.print("Enter the name of the course: ");
String cor;
try{
cor = (new BufferedReader(newInputStreamReader(System.in)).readLine());
courses.remove(cor);
}
catch (Exception e){
e.printStackTrace();
}
System.out.println();
System.out.println();
} //end of 4

if(input ==5)
{
//System.out.println("555555555");
}
}
while(input !=5);


}

}
Here are my errors messages:


ACCCourses.java:7: illegal start of expression
public static Vector<String> courses= newVector<String>();
^
ACCCourses.java:7: ')' expected
public static Vector<String> courses= newVector<String>();
^
2 errors

Explanation / Answer

Please Rate:Thanks

import java.io.*;
import java.util.*;
import java.lang.*;

public class Courses{

public static Vector<String> courses= newVector<String>();


public static void main(String args[]) {

  
int input = 0;  
do{

System.out.println(" type 1 to print the list of courses type 2to lookup some course " +
           " type 3to add a course to the end of the list type 4 to remove a coursefrom the list type 5 to exit the program");
//System.out.print("Enter the number for the opearation you want todo: ");
try{
   input = Integer.parseInt (newBufferedReader(new InputStreamReader(System.in)).readLine());
}
catch (Exception e){
   e.printStackTrace();
}
//input = Integer.parseInt (new BufferedReader(newInputStreamReader(System.in)).readLine());
System.out.println();
if(input ==1)
{
int length = courses.size();
int c=0;
System.out.println("Printing the courses in the list");
while(c<length)
{
System.out.println(courses.elementAt(c));
c++;
}
System.out.println();

} //end of 1


if(input ==2)
{
String cor="";
System.out.print("Enter the word you want to look in the list:");
try{
cor = (new BufferedReader(newInputStreamReader(System.in)).readLine());
}
catch (Exception e){
   e.printStackTrace();
}
System.out.println();
System.out.println();

int length = courses.size();
int c=0;
System.out.println("Looking for the courses in thelist");
while(c<length)
{
String course = courses.elementAt(c);
int j = course.indexOf(cor);
if( j != -1)
System.out.println(course);

c++;
}
System.out.println();
} ///end of 2

if(input ==3)
{
System.out.print("Enter the name of the course: ");
String cor="";
try{
cor = (new BufferedReader(newInputStreamReader(System.in)).readLine());
courses.add(cor);
}
catch (Exception e){
   e.printStackTrace();
}
System.out.println();
System.out.println();

} //end of 3

if(input ==4)
{
System.out.print("Enter the name of the course: ");
String cor;
try{
cor = (new BufferedReader(newInputStreamReader(System.in)).readLine());
courses.remove(cor);
}
catch (Exception e){
   e.printStackTrace();
}
System.out.println();
System.out.println();
} //end of 4

if(input ==5)
{
//System.out.println("555555555");
}
}
while(input !=5);
          

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote