OOPS Karan 1
OOPS Karan 1
OOPS Karan 1
NAME OF EXAMINER :
SIGNATURE OF EXAMINER :
Index
Exp. Page
No. Date Experiment No. Sign
Input/Output Format
13125 8
10
2 1 3 9 2 4 -10 -9 1 3 9
Private members:
Public members:
Input Format
In the void Student::input() function, you must read 5
scores from standard input and save them to your
scores instance variable.
Output Format
In the int Student::calculateTotalScore() function, you
must return the student's total grade (the sum of the values
in scores). The code in the editor will determine how many
scores are larger than
Anna’s and print that number to the console.
Sample Input
The first line contains n, the number of students in Anna’s
class. The n subsequent lines contain each student's 5
exam grades for this semester.
Index
3
30 40 45 10 10
40 40 40 10 10
50 20 30 10 10
Sample Output 1
9 Construct a Program in C++ to show the working of
function overloading(compile time polymorphism) by using
a function named calculate Area () to calculate area of
square, rectangle and triangle using different signatures as
required.
10 Create a class called Invoice that a hardware store might
use to represent an invoice for an item sold at the store. An
Invoice should include four pieces of information as
instance.
Data Members ‐
• partNumber (type String)
• partDescription (type String)
• quantity of the item being purchased (type int)
• price_per_item (type double) Your class should have
a constructor that initializes the four instance variables.
Provide a set and a get method for each instance variable. In
addition, provide a method named getInvoiceAmount() that
calculates the invoice amount (i.e., multiplies the quantity
by the price per item), then returns the amount as a double
value. If the quantity is not positive, it should be set to 0. If
the price per item is not positive,it should be set to0.0.
Write a test application named invoiceTest that
demonstrates class Invoice’s capabilities.
11 Imagine a tollbooth with a class called TollBooth. The two
data items are of type unsigned int and double to hold the
total number of cars and total amount of money collected. A
constructor initializes both of these data members to 0. A
member function called payingCar( )increments the car
total and adds 0.5 to the cash total. Another function called
nonPayCar( ) increments the car total but adds nothing to
the cash total. Finally a member function called display(
)shows the two totals. Include a program to test this class.
This program should allow the user to push one key to
count a paying car and another to count a non paying car.
Pushing the ESC key should cause the program to print out
the total number of cars and total cash and then exit.
Index
12 Create a class called Time that has separate int member
data for hours, minutes and seconds. One constructor
should initialize this data to 0, and another should initialize
it to fixed values. A member function should display it in
11:59:59 format. A member function named add() should
add two objects of type time passed as arguments. A main (
) program should create two initialized values together,
leaving the result in the third time variable. Finally it
should display the value of this third variable
13 Create class SavingsAccount. Use a static variable
annualInterestRate to store the annual interest rate for all
account holders. Each object of the class contains a private
instance variable savingsBalance indicating the amount the
saver currently has on deposit. Provide method For batches
admitted in 2023-24 and 2024-25 onwards, Applicable
from Academic Session 2024-25
calculateMonthlyInterest() to calculate the monthly interest
by multiplying the savingsBalance by annualInterestRate
divided by 12.This interest should be added
tosavingsBalance. Provide a static method
modifyInterestRate() that sets the annualInterestRate to a
new value. Write a program to test class SavingsAccount.
Instantiate two savingsAccount objects, saver1 and saver2,
with balances of Rs2000.00 and Rs3000.00, respectively.
Set annualInterestRate to 4%, then calculate the monthly
interest and print the new balances for both savers. Then
set the annualInterestRate to 5%, calculate the next
month’s interest and print the new balances for both savers
14 Create a class Complex having two int type variable named
real & img denoting real and imaginary part respectively of
a complex number. Overload +, - , == operator to add, to
subtract and to compare two complex numbers being
denoted by the two complex type objects