#include<iostream.h>
#include<fstream.h>
#include<conio.h>
ofstream Ofil("ROW-COLUMNAR.DAT",ios::app);
class application
{
private:
int number;
char application [20];
public:
void accept_data
{
cout<<"enter application: ";
cin>>"application: ";
Ofil<<"application"<<endl;
}
void display_data()
{
char appl;
ifstream Ifill("ROW-COLUMNAR.DAT",ios::app);
while(Ifill)
{
Ifill.getline(appl);
cout<<appl;
}
}
};
class Calculator:application
int mc(int x, int y) //Multiply two numbers
{
cout <<"\n\n"<< x <<" times "<< y <<" equals ";
return (x*y);
}
int ac(int a, int b) //Add two numbers
{
cout <<"\n\n"<< a <<" plus "<< b <<" equals ";
return (a+b);
}
int sc(int z, int c) //Subtract two numbers
{
cout <<"\n\n"<< z <<" minus "<< c <<" equals ";
return (z-c);
}
int calc(char choice)
{
int on,tw,thr;
if (choice == '+') //This whole block checks what the user wants to calculate, and refers to the proper routine to calculate it.
{
cout<<"You selected "<<choice<<". Please enter two numbers,\nsepperated by spaces,";
cout<<"that you want to add."<<endl;//print instructions for the user
cin>>on; //Get the value of variable on
cin>>tw; //Get the value of variable tw
thr=ac(on,tw); //Get the sum of on and tw, and assign that value to thr
cout<<thr<<"\n\n\n\aThanks for using my calculator!"; //Print a thank
}
else if(choice == '-')
{
cout<<"You selected "<<choice<<". Please enter two numbers,\nsepperated by spaces, that you want to subtract."<<endl;
cin>>on;
cin>>tw;
thr=sc(on,tw);
cout<<thr<<"\n\n\n\aThanks for using my calculator!";
}
else if(choice == '*')
{
cout<<"You selected "<<choice<<", Please enter two number,\nsepperated byt spaces, that you want to multiply."<<endl;
cin>>on;
cin>>tw;
thr=mc(on,tw);
cout<<thr<<"\n\n\n\aThanks for using my calculator!";
}
else
{
cout<<"\nPlease reenter that value.\n\a";
cin>>choice;
calc(choice);
}
};
friend class Spell Checker:application
{
cout<<spell checker<<endl;
cin>>"please enter u word: "<<endl;
};
int main()
{
char clrscr();
char choice;
int "one";
int "two";
int "three";
while (choice != 'e')
{
cout<<"\nPlease enter +,-,or *, and then two numbers,\nsepperated by spaces, that you wish to\nadd,subtract or multiply\nType e and press enter to exit.";
cin>>choice;
if(choice != 'e')
{
calc(choice);
}
}
return 0;
}
louis7370 0 Newbie Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
louis7370 0 Newbie Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.