Write the TimesAndInstructors application that stores at least five different college courses (such as CIS101), the time it first meets in the week (such as Mon 9 am), and the instructor (such as Farrell) in a two-dimensional array.
Allow the user to enter a course name and display the corresponding time and instructor. If the course exists twice, display details for both sessions. If the course does not exist, display Invalid Entry: No Such Course.
MY CODE:
import java.util.*;
class TimesAndInstructors {
public static void main(String[] args) {
//storing the courses and times and instructors
String courses[]= {"CIS101","CIS210","MKT100","ACC150","CIS101"};
String time[]= {"Mon 9 am","Mon 11 am","Tues 8:30 am","Tues 6 pm","Fri 1 pm"};
String instructor[]= {"Farrell","Patel","Wong","Deitrich","Lennon"};
Scanner sc = new Scanner(System.in);
System.out.println("Enter course name: ");
String str=sc.next();
boolean flag=false;
for(int i=0;i
if(courses[i].equals(str)) {
flag=true;
System.out.println(str+" ,Time : "+time[i]+", Instructor "+instructor[i]);
}
}
if(!flag)
System.out.println("Invalid Entry: No Such course.");
}
}
Issue:
I don't understand why I have an 85% of this correct, even though it produces the same result