problem with char,boolean and double

B

begum

hi everybody;

I wirte a program but i have some problem. When I enter character or
negative number, the program is crashed.I want it to give me a output
like that " you will enter character or negative number". and i can't
calculate double integers. And my last problem is to change the boolean
function to flag and while operation to for. here is my program

#include<iostream>

#include<string>

#define A 100

using namespace std;

char language;

int main()

{

bool check=false;

char s[A]={0},s1[A]={0};

double val,val1,total=0.0,u=0.0,x[100],p;

char test[10];

int j=0;

cout<<"<T>urkce or <E>nglish : ";

cin>>language;

while(1){

if(language=='t' || language=='T')

cout<<"Ucreti giriniz: <S> dur: ";

else

cout<<"Enter prices or <S> stop: ";

cin>>test;

if(test[0]!='S'){






for(int i=0;test!=NULL;i++){

if(test == '*'){

check=true;

i++;

j=0;

}

if(check==true){


s1[j]=test;

}

else{

s[j]=test;
cout<<test<<"\n";
u+=atoi(test);
cout<<u;
x=u;
p+=x;
cout<<p;
}

j++;

}

j=0;

check=false;

val=atof(s);

val1=atof(s1);

if(val1 != 0)

total += (val1*val);

else

total += val;

// empties the array

for(int empty=0;empty<A;empty++){

s[empty]=NULL;

s1[empty]=NULL;

test[empty]=NULL;

}

}

else{

char quit;



if(language=='t' || language=='T')

cout<<"Toplam Tutar: "<<u<<" YTL
ve KDV "<<total*(0.12)<<"YTL";

else

cout<<"The total is :"<<total<<" $
and VAT is "<<total*(0.12)<<"$";

cout<<endl<<endl;

if(language=='t' || language=='T')

cout<<"<D>evam veya <C>ikis: ";

else

cout<<"<N>ext or <Q>uit: ";

cin>>quit;

if(quit== 'Q' || quit =='C'||quit ==
'q'||quit == 'c')

break;

system("cls");


total=0;

}

}

return 0;

}
 
B

bogdan

hi everybody;

I wirte a program but i have some problem. When I enter character or
negative number, the program is crashed.I want it to give me a output
like that " you will enter character or negative number". and i can't
calculate double integers. And my last problem is to change the boolean
function to flag and while operation to for. here is my program

#include<iostream>

#include<string>

#define A 100

using namespace std;

char language;

int main()

{

bool check=false;

char s[A]={0},s1[A]={0};

double val,val1,total=0.0,u=0.0,x[100],p;

char test[10];

int j=0;

cout<<"<T>urkce or <E>nglish : ";

cin>>language;

while(1){

if(language=='t' || language=='T')

cout<<"Ucreti giriniz: <S> dur: ";

else

cout<<"Enter prices or <S> stop: ";

cin>>test;

if(test[0]!='S'){

for(int i=0;test!=NULL;i++){

if(test == '*'){

check=true;

i++;

j=0;

}

if(check==true){

s1[j]=test;

}

else{

s[j]=test;
cout<<test<<"\n";
u+=atoi(test);
cout<<u;
x=u;
p+=x;
cout<<p;
}

j++;

}

j=0;

check=false;

val=atof(s);

val1=atof(s1);

if(val1 != 0)

total += (val1*val);

else

total += val;

// empties the array

for(int empty=0;empty<A;empty++){

s[empty]=NULL;

s1[empty]=NULL;

test[empty]=NULL;

}

}

else{

char quit;

if(language=='t' || language=='T')

cout<<"Toplam Tutar: "<<u<<" YTL
ve KDV "<<total*(0.12)<<"YTL";

else

cout<<"The total is :"<<total<<" $
and VAT is "<<total*(0.12)<<"$";

cout<<endl<<endl;

if(language=='t' || language=='T')

cout<<"<D>evam veya <C>ikis: ";

else

cout<<"<N>ext or <Q>uit: ";

cin>>quit;

if(quit== 'Q' || quit =='C'||quit ==
'q'||quit == 'c')

break;

system("cls");

total=0;

}

}

return 0;



}- óËÒÙÔØ ÃÉÔÉÒÕÅÍÙÊ ÔÅËÓÔ -- ðÏËÁÚÁÔØ ÃÉÔÉÒÕÅÍÙÊ ÔÅËÓÔ -



http://magegame.ru/?rf=626f6764616e
 
B

bogdan

"""begum ÐÉÓÁÌ(Á):
"""
hi everybody;

I wirte a program but i have some problem. When I enter character or
negative number, the program is crashed.I want it to give me a output
like that " you will enter character or negative number". and i can't
calculate double integers. And my last problem is to change the boolean
function to flag and while operation to for. here is my program

#include<iostream>

#include<string>

#define A 100

using namespace std;

char language;

int main()

{

bool check=false;

char s[A]={0},s1[A]={0};

double val,val1,total=0.0,u=0.0,x[100],p;

char test[10];

int j=0;

cout<<"<T>urkce or <E>nglish : ";

cin>>language;

while(1){

if(language=='t' || language=='T')

cout<<"Ucreti giriniz: <S> dur: ";

else

cout<<"Enter prices or <S> stop: ";

cin>>test;

if(test[0]!='S'){






for(int i=0;test!=NULL;i++){

if(test == '*'){

check=true;

i++;

j=0;

}

if(check==true){


s1[j]=test;

}

else{

s[j]=test;
cout<<test<<"\n";
u+=atoi(test);
cout<<u;
x=u;
p+=x;
cout<<p;
}

j++;

}

j=0;

check=false;

val=atof(s);

val1=atof(s1);

if(val1 != 0)

total += (val1*val);

else

total += val;

// empties the array

for(int empty=0;empty<A;empty++){

s[empty]=NULL;

s1[empty]=NULL;

test[empty]=NULL;

}

}

else{

char quit;



if(language=='t' || language=='T')

cout<<"Toplam Tutar: "<<u<<" YTL
ve KDV "<<total*(0.12)<<"YTL";

else

cout<<"The total is :"<<total<<" $
and VAT is "<<total*(0.12)<<"$";

cout<<endl<<endl;

if(language=='t' || language=='T')

cout<<"<D>evam veya <C>ikis: ";

else

cout<<"<N>ext or <Q>uit: ";

cin>>quit;

if(quit== 'Q' || quit =='C'||quit ==
'q'||quit == 'c')

break;

system("cls");


total=0;

}

}

return 0;

}




http://magegame.ru/?rf=626f6764616e
 
B

BobR

bogdan wrote in message ...[ potential bad link removed]

You quoted ALL that double-spaced program just to post ONE LINE!!!! What a
dud!

TRIM YOUR POSTS!!!

*plonk*
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top