PLEASE HELP....
I was wondering if someone could help me. I am taking a programming class and I am having alot of problems. When I began my class we were given a copy of Visual Studio 2003. I had alot of problems with it and when I would go to build everything would be fine. When I would click to start without debugging was the problem. At the beginning it asks you if you wish to continue but the code does not log off the program when you enter 'n' for some reason. When it goes to enter name of troop it works fine, but then it ends right there. It won't go any farther for some reason. So I downloaded a copy of Visual Studio 2005 and still no luck. I am supposed to be writing a summer fundraiser program for a Boy Scout troop. Each troops fundraising is done on a bonus program. For 300 cans they get 10 points, 301-600 they get 15 points, and 601 and up are 20 points. I can't figure out the code to tally the number of readers, total number of the cans, total number of bonus points, average number of cans, average number of points, and the highest number of points to a single troop.
I am having the hardest time in this class and it is the last class I need to finish. Please someone help??

You'd get a lot more help if you posted your code.

Don't forget the code tags - see the watermark at the back of the edit window, and the "posting code" readme threads at the top of the forum.

PLEASE HELP....
I was wondering if someone could help me. I am taking a programming class and I am having alot of problems. When I began my class we were given a copy of Visual Studio 2003. I had alot of problems with it and when I would go to build everything would be fine. When I would click to start without debugging was the problem. At the beginning it asks you if you wish to continue but the code does not log off the program when you enter 'n' for some reason. When it goes to enter name of troop it works fine, but then it ends right there. It won't go any farther for some reason. So I downloaded a copy of Visual Studio 2005 and still no luck. I am supposed to be writing a summer fundraiser program for a Boy Scout troop. Each troops fundraising is done on a bonus program. For 300 cans they get 10 points, 301-600 they get 15 points, and 601 and up are 20 points. I can't figure out the code to tally the number of readers, total number of the cans, total number of bonus points, average number of cans, average number of points, and the highest number of points to a single troop.
I am having the hardest time in this class and it is the last class I need to finish. Please someone help??

I had a really hard time reading this, break up the post into logical paragraphs.

post your code with the code tags

[ code="cplusplus" ]
[ /code ]

being a java and VB programmer i am not very good in c++ itself but i am reasonably good in program design and pseudocode.

if you are interested explain more specifically what your program must do and i might be able to give you some idea on how to write the logic for the program. :-).

here is a skeleton program which aught to get you started. i suggested something similar to another student asking for help. it is called a sentinel controlled loop. it continuously asks for scout name as well as the number of cans for that scout and will continue to ask until you type "end" where they ask for name. note how the loop says ....while ( scout != "end" )

this code was compiled on Bloodshed's Dev-C++ 4.9.9.2 IDE which uses the ming32 compiler but i say this only if it gives problems on VC++. others better at c++ than myself would then be able to help you. but narue told me that the world has moved on to compilers which works with the standard language so you should have little trouble adapting it to visual c++. I compiled it and it ran. like i said it should get you started.

also i as well as the others said. you are a bit unclear. for example are the scout name and can total to be stored in an array? then declare the array before the loop and add the total to the specific scout's location in the array.
or is it stored in a file( sorry.there i cant help you! i dont know how to open files in c++) then the process is similar but instead of adding to an array you write it to disk. also does a scout brings all his cans at one go or can he come back later with some more( this might require a double loop.). aks if you need more help. sorry for the bad spacing but i have no idea on how to indent the code in a thread.

#include <iostream>
using std::cin; //you probably dont need this because of using namespace std; 
using std::cout; //or this
using std::endl; //or this
using namespace std;
 
 
int main(int argc, char *argv[])
{
string scout;
int cans;
 
//receive first scout name or end to exit program
cout << "Enter the name of the scout. Otherwise type end to exit the program." << endl;
cin >> scout;
 
while ( scout != "end" )
{
cout << "enter the the number of cans" << endl; 
cin >> cans;
 
/* here comes the code which add the cans to some total or write it to a file or something for a given scout whom had his name entered. */
 
//enter next value which could be the sentinel
cout << "Enter the name of the scout. Otherwise type end to exit the program." << endl;
cin >> scout;
 
}
 
//after all the cans are entered 
//average cans = total number of cans divided by number of scouts
 
//and all other code including display the output.
 
system("PAUSE");
return EXIT_SUCCESS;
}

Sorry about the bundle of words. I was very frustrated because my project is due tonight. These problems with Visual Studio are irritating and I don't like it that I can't do my work and check it.
Anyways the project is on a boy scout troop can collection fundraiser. Each troops fundraising is done on a bonus program. For 300 cans they get 10 points, 301-600 they get 15 points, and 601 and up are 20 points. After each troop's name and number of cans is entered it displays the troop name and the number of points they earned. I can't figure out the code to tally: the entire number of troops, the entire number of the cans collected, the entire number of bonus points, average number of cans, average number of points, and the highest number of points to a single troop.
Thanks for the help.

your program requirement has a lot of holes so i shall have to make some assumptions. i have to say that if my boss gives me this scanty info i go back to him and ask him to be more thorough.

i have to asume that you are not interested in printing the number of cans for each scout or the number of bonus point of each scout and therefore i also assume that you are only entering a total for a scout once.

also i am only going to give you the logic with which to flesh out the skeleton program i already gave you; a little heat might teach you not to leave your projects till the last moment again.
i am going to give you two sets of steps to get your averages and highest and after that your just need to output them using cout.

steps to get averages
1. create the following integers before the start of the the loop:
totalCans, totalBonusPoints, totalReaders.
by the way. what is a reader? is it a scout's reading? So that you have one reader for each scout? and also you do of course realise that when i say loop i mean the sentinel controlled while which checks for end.

2. inside the loop, just after receiving the number of cans, do the following:
2.1 add the cans just entered to the totalCans integer.
2.2 use either a switch or a number of if statements, the one below the other, to determine bonus points.
after that add the bonus points for that scout to the total bonus points
do it like this:
if ( cans == 300 )
totalBonusPoints = totalBonusPoints + 10;

if ( cans >= 3001 && cans <= 600 )
totalBonusPoints = totalBonusPoints + 15;

and you can figure out the last one yourself.

2.3. add one( 1 ) to the totalReaders integer. this counts each scout bringing cans.

3. this one is not an instruction. more like a note. when the program runs this logic will be executed multiple times since that is the point of looping. i used sentinel controlled looping since i thought the number of scouts was unknown in advance. if however you know how many scouts there are going to be then you can replace the sentinel controlled while with a for loop if you want. then you would also not need totalReaders since the number of scouts is known.

4. after you have exited the loop you now have totalBonusPoints as well as the totalCans. Since you also have the number of scouts you can now determine the average of bonus and cans.
int averageCans;
averageCans = totalCans / totalReaders;
do something similar for the average bonus.

///////////////////////////////////////////////////////
here are the steps to get the higest bonus and most cans.
1. before the start of the loop.
create integers highstBonus and mostCans.
initialize them both to zero.

2. now inside the loop.
test to see if the cans just received exceed the highest total of cans already received. if it does then re-assign the new highest to the most and highest integers.
like so:
if ( cans > mostCans )
mostCans = cans;

do the same for bonus after you have calculated bonus. you will have to create a new integer for bonus points to hold the bonus points while it is being compared with highestBonus.
this means that instead of adding the bonus points directly to totalBonusPoints you first place them in some integer for example holdBonus. Then after you compare holdBonus with highestBonus you decide whether to make it the new highestBonus and then you add holdBonus to totalBonusPoints.

3. you can also create another string to hold the scout name if that scout has the most cans and highest bonus. just check if his cans is more than mostCans (which you already do) and if it is you put his name in this new string. then you can print his name when you print mostCans. you have to create this string before the while loop and you compare inside the while loop.

//////////////////////////////////////////////
both above sets of steps of course happens simultaneously. i merely seperated them so you can understand easier. once your looping is done( i.e. once the sentinel controlled while ends ) you display the average number of cans, average number of bonus points as well as most cans and most bonus points.

sorry but i cant help you with visual c++. hopefully others will help you there. i myself have switched to Dev-C++ but even there things are a bit thorny.

as far as the above logic is concerned. unlike the skeleton program, i have not tested it. but i am one hundred percent sure that it is right. it might look complex if you are a beginner programmer but you must make an effort to figure it out. programming is all about logic. the above is simple. just follow the steps and use intelligence. (you own not AI! :-))

This article has been dead for over six months. Start a new discussion instead.