Question

Write an application that stores at least five different college courses (such as CIS101), the time...

Write an 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 Johnson) 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.

Use the following values:

Course Time Instructor
CIS101 Mon 9 am Farrell
CIS210 Mon 11 am Patel
MKT100 Tues 8:30 am Wong
ACC150 Tues 6 pm Deitrich
CIS101 Fri 1 pm Lennon

TimesAndInstructors. java

import java.util.*;
class TimesAndInstructors
{
public static void main(String[] args)
{

}
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1


import java.util.Scanner;

public 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);
       //reading the course name
       System.out.println("Enter course name: ");
       String str=sc.next();
       boolean flag=false;
       //iterating through the courses and printig the time and instructor
       for(int i=0;i<courses.length;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.");
   }
}

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me

Add a comment
Know the answer?
Add Answer to:
Write an application that stores at least five different college courses (such as CIS101), the time...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I am currently using eclipse to write in java. A snapshot of the output would be...

    I am currently using eclipse to write in java. A snapshot of the output would be greatly appreciated to verify that the program is indeed working. Thanks in advance for both your time and effort. Here is the previous exercise code: /////////////////////////////////////////////////////Main /******************************************* * Week 5 lab - exercise 1 and exercise 2: * * ArrayList class with search algorithms * ********************************************/ import java.util.*; /** * Class to test sequential search, sorted search, and binary search algorithms * implemented in...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT