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
The program shall:
• generate a random number from 1 to 50 for a player to guess;
• display a message that indicates whether the player's guess is correct, too low, or too high; • prompt the user to keep on guessing until the correct value is entered
4. Create a try-catch structure that will handle two (2) exceptions. These are when the user inputs the following:
• a number that is out of range (1 - 50) a letter or any non-numeric character
5. Prompt the user so that he can guess again if an exception is thrown.
6. Display the number of total guesses.
Note: An invalid input (when an exception is thrown) is not considered a valid guess or attempt.
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
Ram has a list containing 10 integers . you need to help him create a program with separate user defined function to perform the following operation based on this list
· Push the even number into stack
· Pop the content of the stack
· Display content of the stack
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)
DOM Manipulations
The goal of this coding exam is to quickly get you off the ground with the DOM Manipulations.
Use the below reference image.
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.
write a program to find the least common multiple of the given two numbers Mand N
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.