Question

Include a second string auto-implemented property that represents the name of the course’s instructor. Modify the...

  1. Include a second string auto-implemented property that represents the name of the course’s instructor.
  2. Modify the constructor to specify two parameters—one for the course name and one for the instructor’s name.
  3. Modify method DisplayMessage such that it first outputs the welcome message and course name, then outputs "This course is presented by: ", followed by the instructor’s name.

Use your modified class in a test app that demonstrates the class’s new capabilities. NOTE: You will need both a GradeBook file and a GradeBookTest file.

The code from GradeBookTest.cs is:

// Exercise 4.10 Solution: GradeBookTest.cs
// GradeBook constructor used to specify the course name  
// and instructor name at the time each GradeBook object is created.
using System;

public class GradeBookTest
{
   // Main method begins program execution
   public static void Main( string[] args )
   {
      // create GradeBook object
      GradeBook gradeBook1 = new GradeBook(
         "CS101 Introduction to C# Programming", "Sam Smith" );

      gradeBook1.DisplayMessage(); // display welcome message

    Console.WriteLine( "\nChanging instructor name to Judy Jones\n" );
      gradeBook1.InstructorName = "Judy Jones";

      gradeBook1.DisplayMessage(); // display welcome message
   } // end Main
} // end class GradeBookTest

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

//GradeBook.cs

using System;

class GradeBook

{

public string title;

public string InstructorName;

public GradeBook(string tit,string aut)

{

title=tit;

InstructorName=aut;

}

public void DisplayMessage()

{

Console.WriteLine("#########Welcome#########");

Console.WriteLine("Course name: "+title);

Console.WriteLine("This course is presented by: "+InstructorName);

}

}

==========================================================================

using System;

public class GradeBookTest

{

// Main method begins program execution

public static void Main( string[] args )

{

// create GradeBook object

GradeBook gradeBook1 = new GradeBook(

"CS101 Introduction to C# Programming", "Sam Smith" );

gradeBook1.DisplayMessage(); // display welcome message

Console.WriteLine( "\nChanging instructor name to Judy Jones\n" );

gradeBook1.InstructorName = "Judy Jones";

gradeBook1.DisplayMessage(); // display welcome message

} // end Main

} // end class GradeBookTest

================================

//Output

#########Welcome#########
Course name: CS101 Introduction to C# Programming
This course is presented by: Sam Smith

Changing instructor name to Judy Jones

#########Welcome#########
Course name: CS101 Introduction to C# Programming
This course is presented by: Judy Jones

Add a comment
Know the answer?
Add Answer to:
Include a second string auto-implemented property that represents the name of the course’s instructor. Modify the...
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
  • JAVA /** * This class stores information about an instructor. */ public class Instructor { private...

    JAVA /** * This class stores information about an instructor. */ public class Instructor { private String lastName, // Last name firstName, // First name officeNumber; // Office number /** * This constructor accepts arguments for the * last name, first name, and office number. */ public Instructor(String lname, String fname, String office) { lastName = lname; firstName = fname; officeNumber = office; } /** * The set method sets each field. */ public void set(String lname, String fname, String...

  • java programming how would i modify the code below to add a GUI (with a main menu with graphics and buttons, etc...) and include an option to print a list of all students added in a grid format and sh...

    java programming how would i modify the code below to add a GUI (with a main menu with graphics and buttons, etc...) and include an option to print a list of all students added in a grid format and short by name, course, instructor, and location. ///main public static void main(String[] args) { Scanner in = new Scanner(System.in); ArrayList<Student>students = new ArrayList<>(); int choice; while(true) { displayMenu(); choice = in.nextInt(); switch(choice) { case 1: in.nextLine(); System.out.println("Enter Student Name"); String name...

  • Course, Schedule, and ScheduleTester (100%) Write a JAVA program that meets the following requirements: Course Class Cr...

    Course, Schedule, and ScheduleTester (100%) Write a JAVA program that meets the following requirements: Course Class Create a class called Course. It will not have a main method; it is a business class. Put in your documentation comments at the top. Be sure to include your name. Course must have the following instance variables named as shown in the table: Variable name Description crn A unique number given each semester to a section (stands for Course Registration Number) subject A...

  • 1) Introduction to Objects (with Constructors and Properties) We need to answer the question which are...

    1) Introduction to Objects (with Constructors and Properties) We need to answer the question which are below. and instruction are given down starting with part(b). Just we need to copy paste code file and follow the instruction and answer related to them. a) Enter the following program.Answer The questions below the codes, Notice that it consists of two classes that will go into the same project. Please put each class into its own code file (use Lab5_1 for the Project...

  • public class EmployeeDriver public static void main(String[] args) 1/declare create an Employee object named joo. Une...

    public class EmployeeDriver public static void main(String[] args) 1/declare create an Employee object named joo. Une no-arg constructor 1/change the attributes for joe as the following: //name to Joe Cool, id to 1111111, hours to 20, pay rate to 15 //dealare & create another Employee oblegt named one using arg-constructor // The name of the new employees Jane Doeid is 2001122. She makes $10.50/hour // change the object Jane's hours to 40. 1/change the object jane's pay rate to $12.00....

  • public class Pet {    //Declaring instance variables    private String name;    private String species;...

    public class Pet {    //Declaring instance variables    private String name;    private String species;    private String parent;    private String birthday;    //Zero argumented constructor    public Pet() {    }    //Parameterized constructor    public Pet(String name, String species, String parent, String birthday) {        this.name = name;        this.species = species;        this.parent = parent;        this.birthday = birthday;    }    // getters and setters    public String getName() {        return name;   ...

  • The purpose of this is to use inheritance, polymorphism, object comparison, sorting, reading binary files, and...

    The purpose of this is to use inheritance, polymorphism, object comparison, sorting, reading binary files, and writing binary files. In this application you will modify a previous project. The previous project created a hierarchy of classes modeling a company that produces and sells parts. Some of the parts were purchased and resold. These were modeled by the PurchasedPart class. Some of the parts were manufactured and sold. These were modeled by the ManufacturedPart class. In this you will add a...

  • please use java do what u can 1. Modify the Student class presented to you as...

    please use java do what u can 1. Modify the Student class presented to you as follows. Each student object should also contain the scores for three tests. Provide a constructor that sets all instance values based on parameter values. Overload the constructor such that each test score is assumed to be initially zero. Provide a method called set Test Score that accepts two parameters: the test number (1 through 3) and the score. Also provide a method called get...

  • This exercise guides you through the process of converting an Area and Perimeter application from a...

    This exercise guides you through the process of converting an Area and Perimeter application from a procedural application to an object-oriented application. Create and use an object 1. Open the project named ch04_ex2_Area and Perimeter that’s stored in the ex_starts folder. Then, review the code for the Main class. 2. Create a class named Rectangle and store it in the murach.rectangle package. 3. In the Rectangle class, add instance variables for length and width. The, code the get and set...

  • In Java Code Needed is Below the Question Using Program 3: Encapsulating Dogs, modify this program...

    In Java Code Needed is Below the Question Using Program 3: Encapsulating Dogs, modify this program to create a database of dogs of your own. You will also include File I/O with this program. You will create 3 classes for this assignment. The first class: Create a Class representing the information that is associated with one item (one dog) of your database. Name this class Dog. Using Lab 3, this will include the information in regard to one dog. The...

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