Hi, We (me and Jess) went over this same thing over the phone. We thought of adding an additional variable, but decided against it. Come to think of it, this is where vectors, arrays and functions are useful. But he (Jess) knows only while and do while at this point. I could have come up with a function myself, using vectors (push_back) and for loop to add the numbers up. Cheers, Joseph From: programmingblind-bounce@xxxxxxxxxxxxx [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Dale Leavens Sent: Wednesday, July 14, 2010 8:10 PM To: programmingblind@xxxxxxxxxxxxx Subject: Re: Programming assignment, what am I doing wrong? If I understand the assignment correctly you need to analyze the problem more fully and work out the desktop model more precisely before you do your coding. You aren't accumulating the number of registrants from the various companies and you aren't calculating the cost per company. For example you say if registrants are 1 to three then the cost is 150 but that isn't correct. It is the number of registrants times 150. Both the number of registrants and that total for that company must be accumulated and must have the next company information added to it. Only when a negative number is entered is the total accumulated fee divided by the total number of registrants to arrive at the average registration cost. All of this must happen within your loop before the negative number is added then the final average calculation on exit. Have you been introduced to function calls yet? I mean apart from the "main()" function? If so, this would be the place to use one in your loop.You probably should use a float value for your average since this is likely to be a non-integer. Hope I have interpreted the problem correctly and that this is helpful and not confusing the issue further. It is a long time since I programmed in C so I can't comment safely on your syntax. ----- Original Message ----- From: Jes <mailto:theeternalkid@xxxxxxxxx> To: programmingblind@xxxxxxxxxxxxx Sent: Wednesday, July 14, 2010 10:02 PM Subject: Programming assignment, what am I doing wrong? Hi all, HEre is the exact instructions for this programming assignment, along with my code and the errors I am getting. Thanks for any help. ***Programming Assignment: In this exercise, you create a program that displays the registration information for programming seminars. The price per person depends on the number of people a company registers. (For example, if a company registers four people, then the amount owed by that company is $400.) The following chart shows the charges per registrant. Number of registrants Charge per person ($) 1-3 150 4-9 100 10 or more 90 Create an IPO chart for the problem. Use a while loop to allow the user to enter the number of people a company registers. The program should allow the user to enter the number registered for as many companies as desired. Be sure to use an appropriate sentinel value. The program should display the total number of people registered, the total charge, and the average charge per registrant. (For example, if one company registers 4 people and a second company registers 2 people, then the total number of people registered is 6, the total charge is $700, and the average charge per registrant is $116.67.) Open the Ch7AppE04 Solution (Ch7AppE04 Solution.sln) file, which is contained in the Cpp5\Chap07\Ch7AppE04 Solution folder. Use the IPO chart you created in Step a to code the program. Complete a desk-check table for the program. Use 3 as the number of people registered by the first company, 12 as the number registered by the second company, and 9 as the number registered by the third company; then enter your sentinel value. Save and then build the solution. Execute the program. Use the data from Step c to test the program. When the program is working correctly, use the File menu to close the solution. ***My code: //Ch7AppE04.cpp //Displays registration information //Created/revised by <your name> on <current date> #include <iostream> #include <iomanip> using std::cout; using std::cin; using std::endl; //using std::fixed; //using std::setprecision; //declare variables int regNumber = 0; //regNumber is the counter. int totalPrice = 0; //accumulator //Adds number of registrations until user enters negative number to stop acumulating. //The negative number is known as the senteniel value, which is the value which stops the loop. int main() { cout << "Enter number of registrations.\n Press enter after each number.\n Enter a negative number to get the total price: " << endl; cin >> regNumber; do while (regNumber >= 0) { cout << "Enter your next entry. Remember, enter negative number to get total price: " <<endl; cin >> regNumber; +=regNumber; } //endwhile regNumber + total if (regNumber > 1 && regNumber < 3) totalPrice = 150; else if (regNumber > 4 < 9); totalPrice = 100; else if (regNumber > 10) totalPrice = 90; cout << totalPrice; return 0; } //end of main function ***Output results in Visual Studio 2008, after building the solution: ------ Build started: Project: Ch7AppE04 Project, Configuration: Debug Win32 ------ Compiling... cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release Ch7AppE04.cpp c:\course technology\83618-4\cpp5\chap07\ch7appe04 solution\ch7appe04 project\ch7appe04.cpp(29) : error C2143: syntax error : missing ';' before '+=' c:\course technology\83618-4\cpp5\chap07\ch7appe04 solution\ch7appe04 project\ch7appe04.cpp(31) : error C2061: syntax error : identifier 'regNumber' c:\course technology\83618-4\cpp5\chap07\ch7appe04 solution\ch7appe04 project\ch7appe04.cpp(35) : error C2181: illegal else without matching if c:\course technology\83618-4\cpp5\chap07\ch7appe04 solution\ch7appe04 project\ch7appe04.cpp(35) : warning C4804: '<' : unsafe use of type 'bool' in operation c:\course technology\83618-4\cpp5\chap07\ch7appe04 solution\ch7appe04 project\ch7appe04.cpp(36) : warning C4390: ';' : empty controlled statement found; is this the intent? c:\course technology\83618-4\cpp5\chap07\ch7appe04 solution\ch7appe04 project\ch7appe04.cpp(37) : error C2181: illegal else without matching if Build log was saved at "file://c:\Course <file:///c:\Course> Technology\83618-4\Cpp5\Chap07\Ch7AppE04 Solution\Ch7AppE04 Project\Debug\BuildLog.htm" Ch7AppE04 Project - 4 error(s), 3 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== Jes No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.441 / Virus Database: 271.1.1/3003 - Release Date: 07/14/10 18:36:00