Posts

Showing posts from August, 2022
Constructor & Destructor Q.1) Problem1: A common place to buy candy is from a machine. The machine sells candies, chips, gum, and cookies. You have been asked to write a program for this candy machine. The program should do the following: 1. Show the customer the different products sold by the candy machine. 2. Let the customer make the selection. 3. Show the customer the cost of the item selected. 4. Accept money from the customer. 5. Release the item. The machine has two main components: a built-in cash register and several dispensers to hold and release the products. Define class cashRegister in C++ with the following descriptions : Private Members: ● cashOnHand of type integer Public Members: ● A default constructor cashRegister() sets the cash in the register to 500. ● A constructor cashRegister(int) sets the cash in the register to a specific amount. ● A function getCurrentBalance() which returns value of cashOnHand ● A function acceptAmount(int) to receive the amount deposit...

C++ Programming

                                                                CLASS AND OBJECT   Question 1  Define a class student with the following specification  Private members of class student admno integer sname 20 character eng. math, science float total float ctotal() a function to calculate eng + math + science with float return type.  Public member function of class student Takedata() Function to accept values for admno, sname, eng, scienceand invoke ctotal() to calculate total. Showdata() Function to display all the data members on the screen. Code: #include<iostream> using namespace std;  class student { private: int admno; char sname[20]; float eng,math,science; float total; float ctotal() { return eng+math+science; } public: void Takedata() { cout<<"Enter admission number :"<<endl; cin...