CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2011
    Posts
    21

    Question i feel stupid c++

    [code]
    cout<<setw(5)<<"ID#"<<setw(5)<<" "<<left<<setw(15)<<"CATEGORY "<<right<<setw(16)<<"Earned"<<endl;
    cin>>idnum;
    while(!cin.eof())
    {
    cin>>code;
    cout<<fixed<<showpoint<<setprecision(2);
    if(code == 'm' || code == 'M')
    {
    cin>>salary;
    cout<<setw(5)<<idnum<<setw(5)<<" "<<left<<setw(15)<<"Manager"<<"$"<<right<<setw(15)<<salary<<endl;

    }

    cin>>idnum;

    }

    return 0;
    }
    [code]

    i want this
    ID# CATEGORY EARNED
    10051 Manager $ 500.00

    but im getting some weird stuff like this any help
    ID# CATEGORY Earned
    4.86395e-27010025 Manager $ 5.0e+02

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: i feel stupid c++

    Quote Originally Posted by ryamjones View Post
    ...
    i want this
    ID# CATEGORY EARNED
    10051 Manager $ 500.00

    but im getting some weird stuff like this any help
    ID# CATEGORY Earned
    4.86395e-27010025 Manager $ 5.0e+02
    Well, you cannot get "EARNED" just because you output "Earned".
    And what are idnum and salary?

    PS if you debugged your code you, perhaps, already would have got the answer on your problems...
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured