Re: My program runs.

  • From: "Dale Leavens" <dleavens@xxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Thu, 15 Jul 2010 12:59:51 -0400

I'll try to get some time later to look at this in more detail but I think the objective is misunderstood.


It seems to me that you are supposed to input several different company registrations.

Say company a has 15 , company b has 8, company c has 2, you just keep putting in more companies until all of them have had their registrants registered. At that point you put in a negative number as your sentinel value to stop the programme. the programme then calculates the total amount of the fees and the average fee per registrant and prints out the result.

So, within the loop you need your conditional statements to determine what dollar value you multiply the number of registrants by and accumulate that in the total. You also accumulate the number of registrants then get another input value, check it for a negative value and either continue in the loop or leave it and then calculate and display the total amount of money due and the average income per registrant before exiting the programme.

The conditional calculations have to be within the loop, only the final averaging calculation happens outside the loop as well as the display of that number and the total value.

One tip is when using while loops you capture your input before entering the loop because that is where it is tested. You then capture it again immediately before leaving the loop because when flow returns to the top of the loop that is where it is tested. If it fails the test then logic falls to the statement immediately below the loop. You are capturing your input before entering the loop and again immediately into the loop.

This is different than a for -- next loop where the counter value is known entering the loop and that is the significant difference. Do --while loops are intended to repeat iterating when the number of repetitions isn't known at the beginning of the execution. For -- next loops are intended for situation where a pre-determined number of iterations is intended. This number can be altered at execution time by setting a variable value but it is known at the time of entry to the loop how many times precisely it is required.

The point to this programme loop is that you can enter any number of different companies carrying the totals until the batch is done for the day. I see it as an accounting programme for the people offering the course, they want to know how much money they have taken in and how many students there will be and the average fee they end up collecting per student.

Hope this helps.




----- Original Message ----- From: "Jes" <theeternalkid@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Thursday, July 15, 2010 10:56 AM
Subject: My program runs.


After working on this thing for about two or three hours this morning, up tfrom about 3 a m, my code finally works. The program runs, the only thing I need to do now is debug some logic errors. No matter what values I put in, it returns a result of 99. Thanks all for your assistance. If you guys want, I'll put my code in another email.

Jes

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: