Computer Science, asked by anonymous777777, 6 months ago

Write a program for the following:
Define a class Store described as below:
Duta Members: income (double), expenditure (double), net (double)
Member Methods:
(i)Store()-Constructor to initialize member data to null
(ii)Input()-to input values for member data income and expenditure
(iii) Procedure () -to calculate Value of net using the following formula
net = income - expenditure
(iv) Display ( ) -To display all the member data
Write a main() method to create the object of class and call the above member
methods​

Answers

Answered by mad210203
4

Program is given below.

Explanation:

#include <iostream>

using namespace std;

//Class

class Store

{  

//Class members

   double income,expenditure,net;

   public:

   Store()

   {

       income=0;

       expenditure=0;

       net=0;

   }

//Function to input data for data members

   void Input()

   {

       cout<<"Enter your income: ";

       cin>>income;

       cout<<"Enter your Expenditure: ";

       cin>>expenditure;

   }

//This function calculates the value of net

   void Procedure()

   {

       net=income-expenditure;

   }

//This function is used to display values of class members

   void Display()

   {

       cout<<"\n\nIncome: ";

       cout<<income;

       cout<<"\nExpenditure: ";

       cout<<expenditure;

       cout<<"\nNet: ";

       cout<<net;

   }

};

int main() {

   class Store s1;

   s1.Input();

   s1.Procedure();

   s1.Display();

   return 0;

}

Refer the attached image for the output.

Attachments:
Similar questions