Hi everyone,
I have created a program with my whole day and night hard work in dev C++ and now im trying the same code in Visual Studio C++ 6.0 ...
I'm showing you the code of that program, kindly guide me through this, or correct the problem in getting with;
# include <iostream>
# include <string>
#include <iomanip>
#include <stdio.h>
#include <cstdio>
#include <cassert>
#include <fstream>
# include <math.h>
# include <conio.h>
# include <stdlib.h>
using namespace std;
using std::string;
string welcome1();
void welcome2(string n);
int menu();
bool SaleR();
bool Cus();
bool Check();
bool Mile();
void thnk();
int main()
{
cout.setf(ios_base::fixed, ios_base::floatfield);
cout.precision(2);
string nam;
nam = welcome1();
welcome2(nam);
system("pause");
int selection,val;
//man:
do
{
if (selection==1)
{
//cout<<"1 selection ="<<selection;
val=SaleR();
}
if (selection==2)
{
//cout<<"2 selection ="<<selection;
val=Cus();
}
if (selection==3)
{
//cout<<"3 selection ="<<selection;
val=Check();
}
if (selection==4)
{
//cout<<"4 selection ="<<selection;
val=Mile();
}
selection=menu();
//cout<<"0 selection ="<<selection;
if (selection==0)
{
//cout<<"1 selection ="<<selection;
thnk();
}
}
while (selection > 0);
return 0;
}
string welcome1()
{
string n;
system("cls");
cout << "______________________________________________" << endl;
cout << "______________________________________________" << endl;
cout << "____ ____" << endl;
cout << "____ W E L C O M E ____" << endl;
cout << "____ ____" << endl;
cout << "____ T O MAJID ____" << endl;
cout << "____ ____" << endl;
cout << "____ F I N A L ____" << endl;
cout << "____ ____" << endl;
cout << "____ P R O G R A M ____" << endl;
cout << "____ ____" << endl;
cout << "______________________________________________" << endl;
cout << "______________________________________________" << endl;
cout<< endl << endl << endl;
cout << "Enter your first name : " ;
cin >> n;
cout<< endl << endl << endl;
return n;
}
void welcome2(string n)
{
int len = strlen(n.c_str())-1;
cout << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << endl;
cout << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << endl;
cout << "@@@@ @@@@" << endl;
cout << "@@@@ W E L C O M E @@@@" << endl;
cout << "@@@@ @@@@" << endl;
cout << "@@@@"<<setw(17+len)<<n<<setw(21-len)<<" "<<"@@@@" << endl;
cout << "@@@@ @@@@" << endl;
cout << "@@@@ M A Y T H E @@@@" << endl;
cout << "@@@@ @@@@" << endl;
cout << "@@@@ C O M P U T E R @@@@" << endl;
cout << "@@@@ @@@@" << endl;
cout << "@@@@ G O D S H A V E @@@@" << endl;
cout << "@@@@ @@@@" << endl;
cout << "@@@@ M E R C Y @@@@" << endl;
cout << "@@@@ @@@@" << endl;
cout << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << endl;
cout << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << endl;
cout<< endl;
}
int menu()
{
int a;
//system("cls");
cout << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << endl;
cout << "@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@" << endl;
cout << "@@@@@@@@@@@@@@@@@@@ C M P S C 1 0 1 @@@@@@@@@@@@@@@@@@@@" << endl;
cout << "@@@@@@@@@@@@@@@@@@@ F I N A L P R O J E C T @@@@@@@@@@@@@@@@@@@@" << endl;
cout << "@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@" << endl;
cout << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << endl;
cout << "@@@@ @@@@" << endl;
cout << "@@@@ @@@@" << endl;
cout << "@@@@ OPTION DESCRIPTION @@@@" << endl;
cout << "@@@@---------------------------------------------------------"<<"@@@@" << endl;
cout << "@@@@ 1."<<setw(10)<<" Calculate sales tax on multiple sales items "<<"@@@@" << endl;
cout << "@@@@ "<<"@@@@" << endl;
cout << "@@@@ 2."<<setw(10)<<" Create a customer contact card "<<"@@@@" << endl;
cout << "@@@@ "<<"@@@@" << endl;
cout << "@@@@ 3."<<setw(10)<<" Balance a checkbook "<<"@@@@" << endl;
cout << "@@@@ "<<"@@@@" << endl;
cout << "@@@@ 4."<<setw(10)<<" Trip Mileage Report "<<"@@@@" << endl;
cout << "@@@@ "<<"@@@@" << endl;
cout << "@@@@ 0."<<setw(10)<<" Exit "<<"@@@@" << endl;
cout << "@@@@ "<<"@@@@" << endl;
cout << "@@@@ "<<"@@@@" << endl;
cout << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << endl;
cout << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << endl;
cout<< endl;
cout << "Enter your selection here: " ;
cin >> a;
cin.ignore(1,' ');
cout<< endl << endl << endl;
return a;
}
bool SaleR()
{
string Cont;
do
{
system("cls");
float hval,istval,isp,ival,gtot;
string nm;
isp=0.00;
int a=1;
float isTotval=0.00;
cout<<"****************************************************************************"<<endl;
cout<<"* S A L E S R E C E I P T P R O G R A M *"<<endl;
cout<<"* *"<<endl;
cout<<"* This program will print out a detailed reciept that will display...... *"<<endl;
cout<<"* 1: the name of item followed by price *"<<endl;
cout<<"* 2: the total sales price *"<<endl;
cout<<"* 3: the amount of sales tax *"<<endl;
cout<<"* 4: the total purchase price *"<<endl;
cout<<"****************************************************************************"<<endl;
system("pause");
cout <<"\n";
cout <<"\n";
cout <<"\n";
cout<<"Enter in the number of sales items to be calculated : ";
cin>>hval;
float vl[100];
string nam[100];
for (int i=0;i<hval;i++)
{
cout<<"Enter in the name of sales item number "<<a<<" : ";
cin>>nm;
nam[a]=nm;
cout<<"Enter in the price of the "<<nm<<" : $";
cin>>ival;
vl[a]=ival;
a=a+1;
isTotval=isTotval+ival;
}
cout <<"\n";
cout <<"\n";
cout <<"\n";
cout <<"Enter in the sales tax percentage <Enter 10 for 10%>: ";
cin>>istval;
isp=(istval*10/100)*hval;
gtot = isTotval+isp;
a=1;
cout<<"\n";
cout<<"\n";
cout<<"\n";
cout<<"********************************************************"<<endl;
cout<<"************* R E C E I P T O F S A L E S ************"<<endl;
cout<<"********************************************************"<<endl;
cout<<"** ** ** **"<<endl;
cout << "** "<<"Item Names **"<<setw(23)<<"** Price"<<setw(15)<<"**"<< endl;
cout<<"********************************************************"<<endl;
for (int n=0;n<hval;n++)
{
int len = strlen(nam[a].c_str())-1;
cout << "** "<<nam[a]<<setw(28-len) << "$" << setw(9) << vl[a]<<setw(14)<<"**"<< endl;
a=a+1;
}
cout<<"********************************************************"<<endl;
cout << "** Total Sales"<<setw(18) << "$" << setw(9) << isTotval << setw(14)<<"**"<< endl;
cout << "** Sales Tax"<<setw(20) << "$" << setw(9)<< isp << setw(14)<<"**"<< endl;
cout << "**"<<setw(40) << "---------"<< setw(14)<<"**"<< endl;
cout << "** Grand Total"<<setw(18) << "$" << setw(9)<< gtot << setw(14)<<"**"<< endl;
cout<<"** **"<<endl;
cout<<"********************************************************"<<endl;
cout<<"********************************************************"<<endl;
cout<<"\n";
cout<<"\n";
cout <<"\n" << " Do you wants to run this program again? (Y/N):";
//getline(cin, Cont);
cin >> Cont;
}
while (Cont=="Y" || Cont=="y");
if (Cont=="N" || Cont=="n")
{
return 0;
}
}
bool Cus()
{
string Continue;
do
{
system("cls");
string nm,Sadd,ph,stat,cty,zc,fn;
string fName, mName, lName;
char first,last;
cout<<"**********************************************************"<<endl;
cout<<"* C U S T O M E R I N F O R M T I O N F O R M *"<<endl;
cout<<"**********************************************************"<<endl;
//system("pause");
cout <<"\n";
cout <<"\n";
cout <<"\n";
//cin>>lInitial;
cout<<"Enter in the Customer Full Name : ";
getline(cin, nm);
int s = nm.find(' ');
fn=nm.substr(0,s);
first = nm[0];
if (s>0)
last = nm[s+1];
cout <<"\n";
cout<<"Enter in the Customer Stree Address : ";
getline(cin, Sadd);
cout <<"\n";
cout<<"Enter in the Customer City : ";
getline(cin, cty);
cout <<"\n";
cout<<"Enter in the Customer State : ";
getline(cin, stat);
cout <<"\n";
cout<<"Enter in the Customer Zip Code : ";
getline(cin, zc);
cout <<"\n";
cout<<"Enter in the Customer Phone No : ";
getline(cin, ph);
cout <<"\n";
cout <<"\n";
int len = strlen(nm.c_str())-1;
int len2 = strlen(Sadd.c_str())-1;
int len3 = ((strlen(cty.c_str())+strlen(stat.c_str())+strlen(zc.c_str()))+4)-1;
int len4 = strlen(ph.c_str())-1;
int len5 = sizeof(first)+sizeof(last);
//cout<<len3<<" ssd"<<endl;
cout<<fn<<"'s contact card will look as follows:"<<endl;
cout<<"********************************************************"<<endl;
cout<<"******* C U S T O M E R C O N T A C T C A R D ********"<<endl;
cout<<"********************************************************"<<endl;
cout<<"*******"<<setw(23)<<first<<" "<<last<<setw(26-len5)<<"********"<<endl;
cout<<"********************************************************"<<endl;
cout<<"** "<<nm<<setw(51-len)<<"**"<< endl;
cout<<"** "<<Sadd<<setw(51-len2)<<"**"<< endl;
cout<<"** "<<cty<<", "+stat<<" "<<zc<<setw(51-len3)<<"**"<< endl;
cout<<"** "<<ph<<setw(51-len4)<<"**"<< endl;
cout<<"********************************************************"<<endl;
cout<<"\n";
cout<<"\n";
cout <<"\n" << " Do you wants to run this program again? (Y/N):";
getline(cin, Continue);
}
while (Continue=="Y" || Continue=="y");
if (Continue=="N" || Continue=="n")
{
return 0;
}
}
bool Check()
{
string Continue;
do
{
string nm;
int a,amt,bl=0,lwid=0;
int d=0,c=0;
int dep[25];
int wid[25];
int bal[25];
abc:
system("cls");
cout <<"\n";
cout<<"**********************************************************"<<endl;
cout<<"* A C C O U N T I N F O R M T I O N F O R M *"<<endl;
cout<<"**********************************************************"<<endl;
cout <<"** OPTION DESCRIPTION **" << endl;
cout <<"**------------------------------------------------------"<<"**" << endl;
cout <<"** 1."<<setw(10)<<" Cash Deposit"<<setw(30)<<" "<<"**" << endl;
cout <<"** "<<"**" << endl;
cout <<"** 2."<<setw(10)<<" Cash Withdwarl"<<setw(28)<<" "<<"**" << endl;
cout <<"** "<<"**" << endl;
cout <<"** 3."<<setw(10)<<" Balance Sheet"<<setw(29)<<" "<<"**" << endl;
cout <<"** "<<"**" << endl;
cout <<"** 0."<<setw(10)<<" Return Main Menu"<<setw(26)<<" "<<"**" << endl;
cout <<"** "<<"**" << endl;
cout <<"**********************************************************" << endl;
cout<< endl;
cout << "Enter your Account Transction: " ;
cin >> a;
cin.ignore(1,' ');
cout <<"\n";
if (a==3)
{
system("cls");
string z;
cout<<"***********************************************************"<<endl;
cout<<"******* C H E C K B O O K B A L A N C E S H E E T ********"<<endl;
cout<<"***********************************************************"<<endl;
cout <<"\n";
cout <<"\n";
cout<<" DEPOSIT "<<setw(25)<<" WITHDRAWL "<<setw(25)<<" BALANCE "<<endl;
cout<<"***********************************************************"<<endl;
for (int j=0;j<d;j++)
{
cout<<setw(5)<<dep[j]<<setw(50)<<bal[j]<<setw(5)<<endl;
}
for (int i=0;i<c;i++)
{
cout<<setw(30)<<wid[i]<<setw(25)<<bal[d+i]<<setw(5)<<endl;
}
cout<<"***********************************************************"<<endl;
cout<<"Do you want a copy of the check book balance sheet on file? (Y/N)";
cin>>z;
//getline(cin, z);
//cin.ignore(1,' ');
if (z=="Y" || z=="y")
{
FILE *stream ;
if((stream = freopen("output.txt", "w", stdout)) == NULL)
exit(-1);
cout<<"***********************************************************"<<endl;
cout<<"******* C H E C K B O O K B A L A N C E S H E E T ********"<<endl;
cout<<"***********************************************************"<<endl;
cout <<"\n";
cout <<"\n";
cout<<" DEPOSIT "<<setw(25)<<" WITHDRAWL "<<setw(25)<<" BALANCE "<<endl;
cout<<"***********************************************************"<<endl;
for (int j=0;j<d;j++)
{
cout<<setw(5)<<dep[j]<<setw(50)<<bal[j]<<setw(5)<<endl;
}
for (int l=0;l<c;l++)
{
cout<<setw(30)<<wid[l]<<setw(25)<<bal[d+l]<<setw(5)<<endl;
}
cout<<"***********************************************************"<<endl;
fclose (stream);
//return 0;
stream = freopen("CON", "w", stdout);
}
}
if (a==1)
{
//cout <<"\n";
cout<<"Cash Deposit : ";
cin>>dep[d];
cout <<"\n";
bl=bl+dep[d];
bal[d+c]=bl-lwid;
d++;
goto abc;
}
else if (a==2)
{
amt=0;
lwid=0;
//cout <<"\n";
cout<<"Cash Withdwarl : ";
cin>>wid[c];
for (int k=0;k<d;k++)
{
amt=amt+dep[k];
}
for (int l=0;l<c+1;l++)
{
lwid=lwid+wid[l];
}
//cout <<"\n amt ="<<amt<<" lwid ="<<lwid<<endl;;
amt=amt-lwid;
bal[d+c]=amt;
c++;
goto abc;
}
cout <<"\n" << " Do you wants to run this program again? (Y/N):";
cin>>Continue;
//cin.ignore(1,' ');
//getline(cin, Continue);
}
while (Continue=="Y" || Continue=="y");
if (Continue=="N" || Continue=="n")
{
//cin.clear();
return 0;
}
}
bool Mile()
{
//cout.setf(ios_base::fixed, ios_base::floatfield);
//cout.precision(2);
string Cont;
do
{
system("cls");
float hval,istval,isp,ival,nm;
isp=0.00;
int a=1;
float isTotval=0.00;
cout<<"****************************************************************"<<endl;
cout<<"* T R I P M I L E A G E R E P O R T *"<<endl;
cout<<"****************************************************************"<<endl;
cout <<"\n";
cout <<" This program will create a spreadsheet detailing the number of "<<endl;
cout <<" trips and totaling the total mileage owed to the traveler."<<endl;
cout <<"\n";
cout<<"Enter the number of Trips : ";
cin>>hval;
int vl[100];
int nam[100];
float cen[100];
for (int i=0;i<hval;i++)
{
cout <<"\n";
cout <<"\n";
cout<<"Enter in the trip number : ";
cin>>nm;
nam[a]=nm;
cout<<"Enter in the miles for the trip : ";
cin>>ival;
vl[a]=ival;
cout <<"Enter in the miles amount <Enter .50 for 50 cents> :";
cin>>istval;
cen[a]=istval;
a=a+1;
}
cout <<"\n";
cout <<"\n";
cout <<"\n";
a=1;
cout <<" Trip"<<setw(15)<<"Miles"<<setw(17)<<"Cost/Mile"<<setw(15)<<"Expense"<< endl;
cout<<"*****************************************************************"<<endl;
for (int m=0;m<hval;m++)
{
ival=(cen[a]*vl[a]);
isTotval=isTotval+ival;
cout <<" "<<nam[a]<<setw(15)<< vl[a]<<setw(14)<<cen[a]<<setw(14)<<"$"<<(cen[a]*vl[a])<< endl;
a=a+1;
}
cout <<setw(47)<<"$"<<isTotval;
cout<<"\n";
cout<<"\n";
cout <<"\n" << " Do you want tu prepare another mileage speadsheet? (Y/N) :";
cin >> Cont;
}
while (Cont=="Y" || Cont=="y");
if (Cont=="N" || Cont=="n")
{
return 0;
}
}
void thnk()
{
system("cls");
cout << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << endl;
cout << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << endl;
cout << "@@@@ T H A N K Y O U @@@@" << endl;
cout << "@@@@ C O M E A G A I N @@@@" << endl;
cout << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << endl;
cout << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << endl;
system("pause");
}
in the above coding, i m getting problem with the phone number in contact card and balance sheet problem also, which is option 2 and option 3...
if anyone can correct these errors, kindly show me the coding below in your comments..
Regards