Here is the program:
DineOut.h
Code:
class DineOut
{
public:
DineOut(); //void constructor
double FiftyTimes(double x);
double Twice(double x);
double AddFive(double x);
double HadBirth(double x);
double NotHadBirth(double x);
protected:
double x;
};
double FiftyTimes(double x)
{
return x*50;
}
double Twice(double x)
{
return x*2;
}
double AddFive(double x)
{
return x+5;
}
double HadBirth(double x)
{
return x+1753;
}
double NotHadBirth(double x)
{
return x+1752;
}
DineOut.cpp
Code:
#include <iostream>
#include <cstdlib>
#include "DineOut.h"
int main()
{
using namespace std;
int DineOut;
int YearBorn;
int FinalNumber;
int HaveYouHadBirth;
cout<<"DINING OUT MATHEMATICS.\n\n";
system("PAUSE");
cout<<"\n";
cout<<"\t"<<"Here is some really neat math!\n";
cout<<"\a\v";
cout<<"First, enter the number of times that \n";
cout<<"you would like to dine out a week.\n";
cout<<"(This number must be >1 but <10.)";
cout<<"\n\n\t";
cin>>DineOut;
cout<<"\n\n";
cout<<"Now, we will multiply this number by 2.\n";
cout<<"(Just to be bold!)";
cout<<"\n\n\t";
cout<<DineOut<<" x 2 = "<<Twice(DineOut)<<"\n\n";
system("PAUSE");
cout<<"\n\n";
cout<<"Now, we will add 5 for Sunday.";
cout<<"\n\n\t";
cout<<DineOut<<" + 5 = "<<AddFive(DineOut)<<"\n\n";
system("PAUSE");
cout<<"\n\n";
cout<<"Now Multiply it by 50.";
cout<<"\n\n\t";
cout<<DineOut<<" x 50 = "<<FiftyTimes(DineOut)<<"\n\n";
system("PAUSE");
cout<<"\n\n";
cout<<"Now, if you've had your birthday, please press 1. ";
cout<<"\n"<<"If you haven't, please press two.";
cout<<"\n\t";
cin>>HaveYouHadBirth;
if (HaveYouHadBirth==1)
{
cout<<"\n\n";
cout<<"Since you've had your birthday, we'll add 1753.";
cout<<"\n\n\t"<<DineOut<<" + 1753 = "<<HadBirth(DineOut);
cout<<"\n\n";
system("PAUSE");
}
else if (HaveYouHadBirth==2)
{
cout<<"\n\n";
cout<<"Since you haven't had your birthday, we'll add 1752.";
cout<<"\n\n\t"<<DineOut<<" + 1752 = "<<NotHadBirth(DineOut);
cout<<"\n\n";
system("PAUSE");
}
else
{
cout<<"You have not entered a valid number.\a\n\a\n";
system("PAUSE");
cout<<"This program will therefore not work correctly.";
}
cout<<"\n\n";
cout<<"Now, enter the year you were born.";
cout<<"\n\n\t";
cin>>YearBorn;
cout<<"\n\n";
cout<<"Now, we will subtract the year you were born.";
FinalNumber=DineOut - YearBorn;
cout<<"\n\n\t"<<DineOut<<" - "<<YearBorn<<" = "<<FinalNumber;
cout<<"\n\n";
system("PAUSE");
cout<<"\n\n";
cout<<"Finally, you should be left with a three digit number.";
cout<<"\n\t"<<FinalNumber;
cout<<"The first digit is the number of times you would like to\n";
cout<<"dine out a week.\n";
cout<<"The last two numbers are:\n"<<"duh duh duh duuuuuuuuuhhhhhhh!!!\n";
cout<<"YOUR AGE!!! HAHAHA!!!";
system("PAUSE");
return 0;
}