B
begum
hello everyone!
my program is not working properly,
it is not summing the values that i entered.
It should take the double values and add them and also take strings and
makes the * as a multiplacation .
thanks !!!
begum
here is my program
#include<iostream>
#include<string>
#include<iomanip>
#define MAX_INPUT_SIZE 100
using namespace std;
char language;
char temp;
int i;
int k;
double i_error;
double no_star;
char e;
char s;
int main()
{
cout<<"<T>urkce or <E>nglish :";
cin>>language;
while(1)
{
if(language=='E' ||language=='e')
{
cout<<"Enter prices or <S>top:";
cin>>s;if(s =='S' ||s=='s') break;
}
else if(language=='T'||language=='t')
{
cout<<"Fiyat girin veya <S> dur:";
cin>>s;if(s =='S' ||s=='s') break;
}
char temp[MAX_INPUT_SIZE]; //input,
char array; //en basta hepsi NULL'a esit
char part1[MAX_INPUT_SIZE],part2[MAX_INPUT_SIZE] ;
// char array; // en basta hepsi NULL'a esit
int k=0;
int current_operand=1;
double sum, sum1, sum2, total;
if(i_error==0) //processing input
{
for(i=0; i<=MAX_INPUT_SIZE; i++)
{
if(temp!='*'&¤t_operand==1&&temp!=NULL)
{
part1=temp;
}
if(temp!='*'&¤t_operand==2&&temp!=NULL)
{
part2[k]=temp;
k++;
}
if(temp=='*')
{
current_operand=2;
}
}
sum1=atof(part1);
sum2=atof(part2);
if(no_star)
{
sum=sum1;
}
if(!no_star)
{
sum=sum1*sum2;
}
total=total+sum;
}
if(language=='E' ||language=='e')
{
cout<<"The total is "<<setw(12)<<total<< "$ and VAT is "
<<setw(12)<<total*(0.12)<<"$."<<endl;
}
if(language=='T'||language=='t')
{
cout<<"Toplam "<<setw(12)<<total<< "YTL ve
KDV"<<setw(12)<<total*(0.12)<<"YTL."<<endl;
}
if(language=='E'||language=='e')
{
cout<<"<N>ext or <Q>uit:" ;
}
if(language=='T'||language=='t')
{
cout<<"<D>evam veya <C>ikis:";
}
cin>>e;
if(e=='N'||e=='n'||e=='D'||e=='d')
{
system("cls");
}
if(e=='Q'||e=='q'||e=='C'||e=='c')
{
return 0;
}
return 0;
}
}
my program is not working properly,
it is not summing the values that i entered.
It should take the double values and add them and also take strings and
makes the * as a multiplacation .
thanks !!!
begum
here is my program
#include<iostream>
#include<string>
#include<iomanip>
#define MAX_INPUT_SIZE 100
using namespace std;
char language;
char temp;
int i;
int k;
double i_error;
double no_star;
char e;
char s;
int main()
{
cout<<"<T>urkce or <E>nglish :";
cin>>language;
while(1)
{
if(language=='E' ||language=='e')
{
cout<<"Enter prices or <S>top:";
cin>>s;if(s =='S' ||s=='s') break;
}
else if(language=='T'||language=='t')
{
cout<<"Fiyat girin veya <S> dur:";
cin>>s;if(s =='S' ||s=='s') break;
}
char temp[MAX_INPUT_SIZE]; //input,
char array; //en basta hepsi NULL'a esit
char part1[MAX_INPUT_SIZE],part2[MAX_INPUT_SIZE] ;
// char array; // en basta hepsi NULL'a esit
int k=0;
int current_operand=1;
double sum, sum1, sum2, total;
if(i_error==0) //processing input
{
for(i=0; i<=MAX_INPUT_SIZE; i++)
{
if(temp!='*'&¤t_operand==1&&temp!=NULL)
{
part1=temp;
}
if(temp!='*'&¤t_operand==2&&temp!=NULL)
{
part2[k]=temp;
k++;
}
if(temp=='*')
{
current_operand=2;
}
}
sum1=atof(part1);
sum2=atof(part2);
if(no_star)
{
sum=sum1;
}
if(!no_star)
{
sum=sum1*sum2;
}
total=total+sum;
}
if(language=='E' ||language=='e')
{
cout<<"The total is "<<setw(12)<<total<< "$ and VAT is "
<<setw(12)<<total*(0.12)<<"$."<<endl;
}
if(language=='T'||language=='t')
{
cout<<"Toplam "<<setw(12)<<total<< "YTL ve
KDV"<<setw(12)<<total*(0.12)<<"YTL."<<endl;
}
if(language=='E'||language=='e')
{
cout<<"<N>ext or <Q>uit:" ;
}
if(language=='T'||language=='t')
{
cout<<"<D>evam veya <C>ikis:";
}
cin>>e;
if(e=='N'||e=='n'||e=='D'||e=='d')
{
system("cls");
}
if(e=='Q'||e=='q'||e=='C'||e=='c')
{
return 0;
}
return 0;
}
}