Quote:
Originally Posted by ladyluck4772 View Post
My apologies for not using code blocks. Sometimes I do skip over the rules. I will try to do better. Many thanks to Shabbir for doing what I should have been doing. OK, as per previous posts, the company is supposed to be on character, namely a number.

Dear Virxen,
You have been very helpful. However, alot of the changes you have made, we have not covered yet in class. I am a beginning programmer and I'm not sure how my teacher would react to alot of the terms you have used. The farthest we have gotten is using "if, switch, else if, while, and do while." Is there a simpler way to do this? I do not know what the things listed in the block are (if I do the block right, lol). And yes, average is a variable that I forgot to declare. Thank you for your help.

Lori

Code:
//Code Block
  • Item 1 using namespace std;
  • Item 2 char company1[80];
  • Item 3 else if (cin.fail()){//with this you trap errors related with bad input,string instead of number cerr << "Incorrect data!!!" << endl; cin.clear(); cin.ignore(numeric_limits<int>::max(),'\n'); }
I'm sorry, but I cannot figure out how to block the code.



1) change this to
Code:
using std::cout;
using std::cin;
using std::endl;
using std::fixed;
using std::setprecision;
2) remove it and change code like this


Code:
char company=' ';
 .................
  //enter number of registrants
 while (company != 'S' && company != 's'){
    //enter company
    registrants=0;
     cout << "Enter company: ";//inside the while we must read again the company name otherwise there is no chance the program to exit some time
     cin >> company;//we read a string
     getchar();//if you don't want this also, then no solution
.................
3) no other solution --->if you press char instead of number then you can not avoid errors.


did you learn about

Code:
string a;
for example?