problem with char,boolean and double

Discussion in 'C++' started by begum, Dec 6, 2006.

  1. begum

    begum Guest

    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;

    }
    begum, Dec 6, 2006
    #1
    1. Advertising

  2. begum

    bogdan Guest

    On 6 äÅË., 12:26, "begum" <> wrote:
    > 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
    bogdan, Dec 6, 2006
    #2
    1. Advertising

  3. begum

    bogdan Guest

    """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
    bogdan, Dec 6, 2006
    #3
  4. begum

    BobR Guest

    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*
    BobR, Dec 6, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sydex
    Replies:
    12
    Views:
    6,450
    Victor Bazarov
    Feb 17, 2005
  2. lovecreatesbeauty
    Replies:
    1
    Views:
    1,007
    Ian Collins
    May 9, 2006
  3. Replies:
    3
    Views:
    719
  4. J Leonard
    Replies:
    4
    Views:
    12,621
    Mark Space
    Jan 19, 2008
  5. Metre Meter
    Replies:
    7
    Views:
    355
    Metre Meter
    Aug 6, 2010
Loading...

Share This Page