Question

Write a program using OOP to contain the following methods. Use proper constructor and instantine different...

Write a program using OOP to contain the following methods. Use proper constructor and instantine different object to use the specified ,methods. The program must be interactive.

A method called “displayCourse” which displays the name of CS courses offered in Loudoun. (CS200..)

Set Coursename()

Display Course time()

Display Course name()\

HInt: Course info a=new courseInfo()

a.displayCourseTime(name, …)

Course name - CSC 200 , time 9;30 am CSC 201 time : 9:30 am

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

//Oops java code

// CourseInfo.java

public class CourseInfo  

{

private String courseName;

private String time;

  

public CourseInfo()

{

courseName = "";

time = "";  

}

public CourseInfo(String courseName, String time)

{

this.courseName = courseName;

this.time = time;

}

  

public void setcourseName(String courseName) {

this.courseName = courseName;

}

public void setTime(String time) {

this.time = time;

}

public void displaycourseName() {

System.out.print("Course name -" + courseName + ", ");

}

public void displayCourseTime() {

System.out.println("time: " + time);

}

  

public void displayCourse()

{

displaycourseName();

displayCourseTime();

}

public static void main(String[] args)

{

CourseInfo a = new CourseInfo();

a.setcourseName("CSC 200");

a.setTime("9:30 am");

a.displaycourseName();   

a.displayCourseTime();   

CourseInfo b=new CourseInfo();

b.setcourseName("CSC 201");

b.setTime("9:30 am");

b.displayCourse();

}

}

Terminal . (137, 60%) 10:05 PM ubuntu 1 // Courses.java 4 public class CourseInfo private String courseName: private String time; eubuntu@ayushv: ~/Desktop/codes/HomeworkLibsolution ubuntucayushv: /Desktop/codes/HomeworkLibsolutions javac CourseInfo.java ubuntu-ayushv: . Desktop /codes/HomeworkLibsoluti java CourseInfo Course name -CSC 200, tine: 9:30 am Course name -CSC 20, tine: 9:30 am ubuntucayushv: /Desktop/codes/HomeworkLibsolution$ public CourseInfo) 10 courseName time 12 13 14 15 16 17 18 19 20 21 public CourseInfo(string courseName, String time) this.courseNamecourseName; this.time time; public void setcourseName(String courseName) this.courseName-courseName 23 24 public void setTime(String time) this.time time; 26 27 28 29 30 31 32 public void displaycourseName) System.out.print(Course name -courseName + ) public void displayCourseTime) System.out.println(time:time; 34 35 36 37 38 39 public void displayCourse) displaycourseName); displayCourseTime); 42 43 public static void main(Stringl] args) CourseInfo a -new CourseInfo) 45 46 47 a.setcourseName( CSC 280) Line 36, Column 20 Spaces: 4 Java

Add a comment
Know the answer?
Add Answer to:
Write a program using OOP to contain the following methods. Use proper constructor and instantine different...
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
  • Write java program The purpose of this assignment is to practice OOP with Array and Arraylist,...

    Write java program The purpose of this assignment is to practice OOP with Array and Arraylist, Class design, Interfaces and Polymorphism. Create a NetBeans project named HW3_Yourld. Develop classes for the required solutions. Important: Apply good programming practices Use meaningful variable and constant names. Provide comment describing your program purpose and major steps of your solution. Show your name, university id and section number as a comment at the start of each class. Submit to Moodle a compressed folder of...

  • Design a JAVA class called Course. The class should contain: ○ The data fields courseName (String),...

    Design a JAVA class called Course. The class should contain: ○ The data fields courseName (String), numberOfStudents (int) and courseLecturer (String). ○ A constructor that constructs a Course object with the specified courseName, numberOfStudents and courseLecturer. ○ The relevant get and set methods for the data fields. ○ A toString() method that formats that returns a string that represents a course object in the following format: (courseName, courseLecturer, numberOfStudents) ● Create a new ArrayList called courses1, add 5 courses to...

  • Need a Javascript program for an Employee class with a Constructor Function. It must contain properties...

    Need a Javascript program for an Employee class with a Constructor Function. It must contain properties of name, annualsalary and bonus of multiple employee of a company. It should contain a Method for calculateBonus. The bonus will be 20% of annualsalary. When the calculateBonus method is called, the bonus should be returned as the bonus's return value. Create a Function Called checkEmployee(). This Function when called will instantiate an employee Object Will Call the Employee's calculateBonus Method and when the...

  • In C++, Step 1: Implement the Student Class and write a simple main() driver program to...

    In C++, Step 1: Implement the Student Class and write a simple main() driver program to instantiate several objects of this class, populate each object, and display the information for each object. The defintion of the student class should be written in an individual header (i.e. student.h) file and the implementation of the methods of the student class should be written in a corresponding source (i.e. student.cpp) file. Student class - The name of the class should be Student. -...

  • Using Phyton. Design a class Country with the use of constructor, mutator, accessor methods and implement...

    Using Phyton. Design a class Country with the use of constructor, mutator, accessor methods and implement that class to store the name of the countries, their population, their areas and regions they are located. Then write a program that reads 5 instances (US, China, Russia, Germany, India) of country class and display the name of the country, the population, the area and the region they are located.

  • Write the following program in C++. Review structures, pointers and dynamic memory allocation from CSIT 839....

    Write the following program in C++. Review structures, pointers and dynamic memory allocation from CSIT 839. Also, review pointers and dynamic memory allocation posted here under Pages. For sorting, you can refer to the textbook for Co Sci 839 or google "C++ sort functions". I've also included under files, a sample C++ source file named sort_binsearch.cpp which gives an example of both sorting and binary search. The Bubble sort is the simplest. For binary search too, you can refer to...

  • In C++ Write a program that contains a class called VideoGame. The class should contain the...

    In C++ Write a program that contains a class called VideoGame. The class should contain the member variables: Name price rating Specifications: Dynamically allocate all member variables. Write get/set methods for all member variables. Write a constructor that takes three parameters and initializes the member variables. Write a destructor. Add code to the destructor. In addition to any other code you may put in the destructor you should also add a cout statement that will print the message “Destructor Called”....

  • In order to do Program 6, Program 5 should bemodified.Program 6

    In order to do Program 6, Program 5 should be modified.Program 6-----------------------------------Program 4----------------------------------------------- (abstract class exception handling) Modify program4 to meet the following requirements: I. Make Person, Employee classes to abstract classes. Cl0%) 2. Add an interface interface working with a method teach() (5%) interface working void teach(String course) J 3. Modify Faculty class. (20%) a. a private data field and implement existing b. Modify Faculty class as a subclass of addition to the c. toString or print Info) method to...

  • Write a class named blend. The blend class should contain me the quantity of the total...

    Write a class named blend. The blend class should contain me the quantity of the total coffee in the blend (in pounds), the time of the roast (in hours use a double) of the blend, the name of the blend, and predicted yield in gallons of the blend. Each blend may contain up to three different coffees and will contain the pounds of each used. The blend should have a constructor and applicable methods and be able to display each...

  • Lab 2 (ADTs) 1) LockADT – Show the interface and all abstract methods LockDataStructureClass – Show the following methods: default constructor, overloaded constructor, copy constructor, setX, setY, s...

    Lab 2 (ADTs) 1) LockADT – Show the interface and all abstract methods LockDataStructureClass – Show the following methods: default constructor, overloaded constructor, copy constructor, setX, setY, setZ, alter (change the lock’s combination to the numbers passed) turn (use for loops to show the dial turning), close (locks the lock), attempt (tries to unlock the lock – calls turn( ), inquire (locked or unlocked), current (returns the number the dial is pointing to), toString LockClientDemoClass – You should have a...

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
ADVERTISEMENT