Write a program having a base class Student with data member rollno and
member functions getnum() to input rollno and putnum() to display rollno. A class
Test is derived from class Student with data member marks and member functions
getmarks() to input marks and putmarks() to display marks. Class Sports is also
derived from class Student with data member score and member functions getscore()
to input score and putscore() to display score. The class Result is inherited from two
base classes, class Test and class Sports with data member total and a member
function display() to display rollno, marks, score and the total(marks + score).
Write a class Teacher that contains the attribute teacher name, age and address. It
also contains member function to input and display its attributes. Write another class
Author that contains the attributes author name, address and number of books written
by him. It also contains member functions to input and display its attributes. Write a
third class Scholar that inherits both Teacher and Author classes. Test these classes
from main() by creating objects of derived classes and testing functions in a way that
clear concept of multiple Inheritance.
Create a class Person having name, age and gender as its data members. Create
another class Employee which has employername and dailywages as it data member.
From these two classes derive another class teacher which contains teacher grade as
data member.
i. Write set and get functions to enter and display the data members.
ii. Write main function to implement these classes. Enter the teacher data to show
multiple inheritance.
Create a Class named base which has two data members. Then derive a class
derived1 from base class which has one data members. Derive a class derived2 from
derived1.
i. Write functions for each class to get and display values.
ii. Write main() function to create object of derived2 and through that object
access the data member of base class and derived1 class
Write a function template to add two numbers. Overload the function template to add three numbers. The third template argument should have the default value as <int> . When the function is called with char type of arguments, the characters should be concatenated to form a string.
Practice programs: Consider a book shop which sells both books and video tapes. Create a class media that stores the title and price of a publication. Derive two classes from media, one for storing the number of pages in a book and another for storing playing time of a tape. Write a C++ program using run time polymorphism to implement it.
Write a c++ program that will compute the gross pay of the employee after 5 days work. The gross pay is the number of hours work per day plus the bonus pay after it reach the 5 day quota, see below table. The employee is paid 100 pesos per hour
The Bonus is computed in percentage of the total salary the employee earn.
At the end of the program it will ask the user to run the program again or terminate. If to run, it will loop from the beginning of the program.
Total Hours Work Bonus Percentage
Below 40 Hours 0
40-55 Hours + 5%
56-65 + 10%
65 above + 15%
Total Salary = Total Number of Hours work x 100
Gross Pay = Total Salary + Bonus
Sample:
>>Hours work day 1: 8
>>Hours work day 2: 9
>>Hours work day 3: 10.5
>>Hours work day 4: 5
>>Hours work day 5: 10
>> Your gross pay for the week is 4462.5
>> Do you want to continue? Y if Yes or press other key to exit: h
>>
C++ Code
Competition Score
the assignment must have a score system of 10 points from 10 judges, for the 10 athletes that are participating in the competition, the score should be from 0 to 10 from each judge to the 10 athletes. an example for one of the 10 athletes is shown below.
Jake Miller's results:
8.10, 7.10, 9.40, 7.20, 9.20, 6.40, 9.50, 8.40, 6.70, 6.60
The highest score of 9.50 and the lowest score of 6.40 were dropped
The average score is 7.84
Code the following non-member functions:
1. A non-member function getStudInfo that receives a file name along with an array of
student objects. This function will use the data given in a file called studMarks.csv to
populate an array of students accordingly. You can assume the given file contains valid
data for each student. Figure 2 shows the contents of the given csv file, the sequence of fields is as follows : student_number,gender,subject_code,mark1,mark2,mark3
. Write non-member function sortDescending that will sort all student objects in descending order according to year mark (predicate).Make use of your overloaded operator(s).
3. Write a non-member function displayStudentInfo that will display all sorted student information. Output should be displayed as shown in the sample output; marks will not
be awarded if this is not adhered to.
4. Write a non-member function calcAvgForSubject that calculates and displays the average year mark of students doing a given subject.
Create a class called Student; this class is inherited from the Subject class.
This class must have the following data members:
A student number, for example “200605544”.A character member for storing a student gender, for example ‘M’ for male and ‘F’ for female
This class must have the following methods:
A public default constructor that sets data members to appropriate default values.A setStudent method that provides the relevant data members with valid
supplied values. Ensure that a student number is not an empty string and that
only M/mF/f are supplied for gender.A method called getStudNum that returns a student number.A method called getGender that returns a student’s gender, for example
“Female”.An overloaded + operator that will accumulate the year marks of two or more students An overloaded > operator that checks if one student’s year mark is greater than
another students’ An overloaded == that checks a student’s subject code against a given value