Define a class Student with the following specification:
PRIVATE DATA MEMBERS:
regno integer sname 20 character s1, s2. s3 float total float
PUBLIC MEMBER FUNCTIONS:
Student() Default constructor to initialize data members, s1 = s2 = s3 = 0
Student(rn, sn, m, p, c) Parameterized constructor accept values for regno, sname, s1, s2 and s3
calculate() Function to calculate the student total marks
putdata() Function to display all the data members of student
~student() Destructor to destroy the data objects
Create the class Student consisting of data members register_no and name. Define array of objects by using constructor Student() to assign the values for the class Student data members, display() member function is used to display the information of student. Finally free the resources of data objects using destructor member function. (Note: Define object size of two)
Design a C++ program having a base class Student with data member rollno and member functions getnum() to input rollno and putnum() to display rollno. The class Test is derived from class Student with data member marks (Three subject marks) and member functions getmarks() to input marks and putmarks() to display marks. The class Sports is also derived from class Student with data member score (range between 100) 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).
The postage for ordinary post is Rs. 2.00 for the first 15 grams and Rs. 1.00 for each additional 10 grams. Write a C++ program to calculate the charge of postage for a post weighting N grams. Read the weights of N packets and display the total amount of postage using multiple inheritance.
* Base class-1: Member variables are name, source and destination.
* Base class-2: Member variables are no. of packets and weight.
* Derived class: Member functions display(), displays the name, source, destination, total weight and total amount.
Design class Seller to determine whether the seller has made profit or incurred loss. Also determine how much profit he made or loss he incurred. Cost price and selling price of an item is the data member of the class which is input data given by the user. Include the following member function
getItemDetails()- to get item details
dtermineProfitLoss()- to determine whether the seller has made profit or incurred loss
showItemDetails()- to get item details with Profit or loss.
Sample Input and Output
Test cases
Input
Output
Test case 1
800
800
No profit no loss
Test case 2
800
900
profit=100
Test case 3
800
700
Implement a C++ program to overload the function named as sum, to perform sum of digits of integer and perform sum of digits of float number respectively.
Write a class TimeStamp that represents a time of the day. It must have variables to store the number of seconds, minutes and hours passed. It also must have a function to print all the values. You will also need to overload a few operators.
Task 1: Create a list of objects of class TimeStamp. Task 2: Insert 5 time values in the format ssmmhh
i. 15 34 23
ii. 13 13 02
iii. 43 45 12
iv. 25 36 17
v. 52 02 20
Task 3: Delete the timestamp 25 36 17
Task 4: Print the list
Output should be: 15:34:23
13:13:02
43:45:12
52:02:20
Design a pay roll system to find the employee total salary using single inheritance. The base class employee consisting of data members such as emp_number and emp_name. The derived class salary consisting of data members such as Basic_pay, HRA, DA, PF, Net_pay.
Creates two friendly classes, the class ABC with attribute A and class XYZ with attribute age to find maximum age among two men. Assign values for the data members using parameterized constructor, then to find maximum age among two men using friend function and display the age of men. Finally free the resources of data objects using destructor member function.
Read the PAN Number and Name of an Employee. If the PAN Number does not contain exactly 10 characters and if the Name of the Employee is empty throw an IllegalArgumentException. If the PAN Number contains any character other than digits and alphabets(Vice versa), throw a NoSuchElementException. Considering the PAN number starts with 0 to 9 position, check for 0th to 4th (including 4th position) to be alphabets, check for 5th to 8th position (including 5th &8th position) of the PAN Number to be digit, again 9th positon must be alphabet and also 4th position of the PAN Number should be the First Letter of the employee's Name. If all the cases are valid for PAN Number print the message ‘valid’ else ‘invalid’.