Create two classes and a main function and save it in a file with your +PR1.cpp for the following class definitions and main instructi

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

DO IT IN C++

### Programming Exercise: Class Definitions and Main Function

#### Task Overview:
Create two classes and a main function, and save the file as `<lastname>+PR1.cpp` using the following instructions for class definitions and main functionality.

#### Class Definitions:

**Course**
- **Attributes:**
  - `+number` (string)
  - `+credits` (int; must be a value greater than 0)
- **Constructors and Methods:**
  - Accessors, mutators, default constructor
  - Default constructor initializes `number` to "CSC101" and `credits` to 3
  - Overloaded constructor accepts two parameters for `number` and `credits`

**Student**
- **Attributes:**
  - `+name` (string)
  - `+enroll` (Course)
- **Constructors and Methods:**
  - Accessors, mutators, default constructor
  - Default constructor initializes `name` to an empty string

#### Main Function Instructions:

1. Declare a `string` variable named `cnumber`.
2. Declare an `int` variable named `ccredits`.
3. Declare a `string` variable named `sname`.
4. Instantiate a `Course` object called `c1` using its default constructor.
5. Input a `string` from the keyboard and store it in `cnumber`.
6. Set `c1` object's `number` attribute to `cnumber`.
7. Input an `int` from the keyboard and store it in `ccredits`.
8. Set `c1` object's `credits` attribute to `ccredits`.
9. Create a `Course` object called `c2` using its overloaded constructor with `number` set to "CSC350" and `credits` set to 4.
10. Create another `Course` called `c3` using its default constructor.
11. Set `c3` object's `number` attribute to "ELECTIVE".
12. Set `c3` object's `credits` to the sum of `c1` and `c2` objects' `credits`.
13. Declare a `Student` object called `s1` using the default constructor.
14. Input a `string` from the keyboard and store it in `sname`.
15. Set `s1` object's `name` attribute to `sname`.
16. Set `s1` object's `enroll`
Transcribed Image Text:### Programming Exercise: Class Definitions and Main Function #### Task Overview: Create two classes and a main function, and save the file as `<lastname>+PR1.cpp` using the following instructions for class definitions and main functionality. #### Class Definitions: **Course** - **Attributes:** - `+number` (string) - `+credits` (int; must be a value greater than 0) - **Constructors and Methods:** - Accessors, mutators, default constructor - Default constructor initializes `number` to "CSC101" and `credits` to 3 - Overloaded constructor accepts two parameters for `number` and `credits` **Student** - **Attributes:** - `+name` (string) - `+enroll` (Course) - **Constructors and Methods:** - Accessors, mutators, default constructor - Default constructor initializes `name` to an empty string #### Main Function Instructions: 1. Declare a `string` variable named `cnumber`. 2. Declare an `int` variable named `ccredits`. 3. Declare a `string` variable named `sname`. 4. Instantiate a `Course` object called `c1` using its default constructor. 5. Input a `string` from the keyboard and store it in `cnumber`. 6. Set `c1` object's `number` attribute to `cnumber`. 7. Input an `int` from the keyboard and store it in `ccredits`. 8. Set `c1` object's `credits` attribute to `ccredits`. 9. Create a `Course` object called `c2` using its overloaded constructor with `number` set to "CSC350" and `credits` set to 4. 10. Create another `Course` called `c3` using its default constructor. 11. Set `c3` object's `number` attribute to "ELECTIVE". 12. Set `c3` object's `credits` to the sum of `c1` and `c2` objects' `credits`. 13. Declare a `Student` object called `s1` using the default constructor. 14. Input a `string` from the keyboard and store it in `sname`. 15. Set `s1` object's `name` attribute to `sname`. 16. Set `s1` object's `enroll`
Expert Solution
steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education