Kamal would like to withdraw X Rs from an ATM. The cash machine will
only accept the transaction if X is a multiple of 100, and kamal's account balance has enough cash to
perform the withdrawal transaction. For each
successful withdrawal the bank charges 50 Rs. Calculate Kamal's account
balance after an attempted transaction.
Consider the definition of the following class:
class Sample
{
private:
int x;
double y;
public :
Sample();
//Constructor 1
Sample(int);
//Constructor 2
Sample(int, int);
//Constructor 3
Sample(int, double);
//Constructor 4
};
i. Write the
definition of the constructor 1 so that the private member variables are initialized
to 0.
ii. Write the
definition of the constructor 2 so that the private member variable x is
initialized according to the value of the parameter, and the private member
variable y is initialized to 0.
iii. Write the definition of the constructors 3 and 4 so that the private
member variables are initialized according to the values of the parameters
Consider the class declaration and main() function below. There are two errors in
the main() function. Name the errors and explain how to fix them, providing all the
code required to correct the errors.
class Game
{
public:
Game();
string getName();
int getLevel();
double getScore();
private:
string Name;
string Champion;
int Level
double Score;
};
int main()
{
Game sodoku, tetris[12];
.........(additional code)
double nScore = sodoku.Champion;
.........(additional code)
return 0;
cout << "The first tetris player is "
<< tetris.getName() << endl;
}
The science museum has asked you to write a c++ application that children can use to find the total number of hours and years slept during their lifetime. Assume they slept at an average of 8 hour per night. The user should enter the name, birthday, year and current year.
Name - Mercy
day - 01
year - 1999
Current year - 2021
To calculate the number of hours slept. Assume 365 day per year, 30 day per month and 8 hours of sleep per day. The program should show how many years, month, weeks, days, hours, minutes, seconds the child slept in this lifetime.
Note : use classes, function, and control structures to achieve this task. the user will also determine the number of children the process.
the science museum has asked you to write a c++ application that children can use to find the total number of hours and years slept during their lifetime. assume they slept at an average of 8 hour per night. the user should enter the name, birthday, year and current year. to calculate the number of hours slept. 365 day per year, 30 day per month and 8 hours of sleep per day. the program should show how many years, month, weeks, days, hours, minutes, seconds the child slept in this lifetime. note use classes, function, and control structures to achieve this task. the user will also determine the number of children the process
The MUSEUM has asked you to write a C++ applicationt that children can use to find the total number of hours and years slept during their lifetime. Assume they slept at an average of 8 hour per night. the user should enter the name, birthday, year and current year. To calculate the number of hours slept. 365 day per year, 30 day per month and 8 hours of sleep per day. The program should show how many years, month, weeks, days, hours, minutes, seconds the child slept in this lifetime
How we can access the private and protected members of class in other class or function without using inheritance. Write Example of Weight class which has two private data members kg and gram.There is a nonmember function AddTen() which object of weight class and adds the values ten to kg and gram.