y using if-else statement write a C++ program to input marks of five subjects
Physics, Chemistry, Biology, Mathematics, and Computer. Calculate the percentage
and grade according to the following rules:
Percentage >= 90%: Grade A
Percentage >= 80%: Grade B
Percentage >= 70%: Grade C
Percentage >= 60%: Grade D
Percentage >= 40%: Grade E
Percentage < 40%: Grade F
Write a program that takes input of the number of rows and then prints the diamond for the given number of rows using loops
Sample diagram
A
BCD
EFGH
IJKLMN
OPQRS
UWX
Y
class Distance with two private data members:
feet: An integer that holds the feet.
inches: An integer that holds the inches.
Write a constructor with default parameters that initializes each data member of the class.
If inches are greater than equal to 12 then they must be appropriately converted to
corresponding feet.
.
o void setFeet(int f) and int getFeet()const
o void setInches(int i) It should ensure proper conversion to feet.
o int getInches() const
Define an operator ‘+’ that overloads the standard ‘+’ math operator and allows one
Distance object to be added to another. Distance operator+ (const Distance &obj).
Define an operator - function that overloads the standard ‘-‘ math operator and allows
subtracting one Distance object from another. Distance operator-(const Distance &obj)
Define an operator= function that overloads the = operator and assign one Distance object to another. const Distance operator=(const Distance &obj)
Develop a C++ class named Complex
Complex to hold complex numbers data. The class should support functionality to support computation of complex conjugate, magnitude, phase and to print the number in format x+i(y)
x+i(y) where x
x is real and y
y is imaginary part. Provide at least three (default, copy and set by values) constructors.
Also, overload the four basic arithmetic operators(+, -, *, /) and write code to use those implementations.
We want to create a class of Product that contains multiple private data members such as
quantity: An integer that holds a count value.
objCount: A static integer that holds that count of objects.
serialNo: An integer that holds the serial number of objects of a specific product (assume
the single object of Product class).
Define a constructor that can accept two arguments i.e., totalQuantityOfProduct and
serialNumberOfProduct; and assign it to the respective data members of the class.
Moreover, the static member be shall be initialized from the outside of the class with zero
by using scope resolution operator.
Define operator = that add the value of quantity to the left hand operand. i.e. c2=c1 (the
quantity of object c2 shall be incremented with the quantity of c1).
Define unary operator - that inverts the value of quantity for product class and should
allow the statements like c1 -= 4;
Execute the provided testCases.
class named Matrix that shall contains private data member
matrix: integer type array of size 3 by 3;
constructor that should have default parameters that can set all elements to 0. Moreover, define a function called setMatrixValues(int matrixArray[3][3]) that can assign values of matrixArray (provided to the function in argument) to the matrix array (data member of the class Matrix) of the class. Along with it, define a function called displayMatrix() that can display all values of the matrix.
class named Matrix that shall contains private data member
matrix: integer type array of size 3 by 3;
constructor that should have default parameters that can set all elements to 0. Moreover,define a function called setMatrixValues(int matrixArray[3][3]) that can assign values of matrixArray (provided to the function in argument) to the matrix array (data member of the class Matrix) of the class. Along with it, define a function called displayMatrix() that can display all values of the matrix.
You are supposed to construct a class Date that shall contains the following private members
such as:
Day: integer type data.
Month: integer type data.
Year: integer type data.
You are supposed to perform operators overloading on the following operators
> : greater than operator.
< : less than operator.
== : equal operator.
A car park has the following charges. The 1st hours cost RM2.00. The sub sequent hours cost RM1.00 per hour. Write a program for this problem.
A student’s letter grade is calculated according to the following schedule:
Using this information, write, compile, and run a C++ program that accepts a student’s numerical grade, converts the numerical grade to an equivalent letter grade, and displays the letter grade.
Write a class Account with following parameters: accountTitle (string), accountHolder (string), accountNumber(string), amount(double). Write public getters and setters for each class variable. You are also required to write following functions
1. withdrawAmount The user should be able to withdraw amount from his/her account. The withdrawAmount member function.
2. deductTax At every withdrawal, The program should be able to deduct tax (2.5%) from user amount.
Write main() function where program should provide following options to the user:
a. create account
b. set account title
c. set account holder name
d. set account number
e. set amount
f. get account title
g. get account holder name
h. get account number
i. get amount
j. withdraw amount
k. deduct taxes