|
|
|
#21 (permalink) | ||||||||||||||
|
i click home too much
|
ahhh reminds me of my old program i made along time ago. it calculated how may times a ball will bounce and the feet between each bounce with givin variables. nice job man.
__________________
Quote:
|
||||||||||||||
|
|
|
|
#22 (permalink) | |||||||||||||
|
New to Overclock.net
|
I think case 7 can be shortened.
__________________I dont remember exactly anymore because its been 2-3 years, but i think there is a function that compresses those.
|
|||||||||||||
|
|
|
|
|
#24 (permalink) | |||||||||
|
Chiefly Ignorant
|
Quote:
Code:
int menuchoice = -1;
while(menuchoice != 14)
{
cin >> menuchoice;
performOperation(menuchoice);
}
__________________
|
|||||||||
|
|
|
|
#25 (permalink) | |||||||||||||
|
Overclocker
|
I didn't have time at work to look through the whole thing, but I can make a couple quick suggestions for the calculator.
1. For subtraction, why are you making the user enter the larger number first? Can you not figure out a way to handle negative numbers? 2. For division, you should have a guard against dividing by 0, otherwise it will crash the program. And like I saw someone else say, you should also check to make sure the input is actually a number. You say you are in your first month of programming? Looking good ![]()
__________________
Manufacturing Consent is the Name of the Game --------------------------------------------------------------- ---------------------------------------------------------------
|
|||||||||||||
|
|
|
|
#26 (permalink) | ||||||||||||
|
Overclocker in Training
|
looks pretty exciting.
|
||||||||||||
|
|
|
|
|
#27 (permalink) | ||||||||||||||
|
Audiophile
|
I hate programming.
![]()
__________________
Bent LGA pins?! Never fear the solution is here! ╩╪Unofficial Lego Lovers Club╩╪ For sale: Pentium 4 2.8 GHz Northwood & 478 Biostar P4M900-M4 Motherboard Quote:
|
||||||||||||||
|
|
|
|
|
#28 (permalink) | ||||||||||||
|
Overclocker in Training
|
haha booo!
|
||||||||||||
|
|
|
|
|
#29 (permalink) |
|
New to Overclock.net
|
Ok I added some suggestions you guys stated I am still having errors and problems with getting the "loop" idea to work right lol.
I added like 5-6 new options and made the program ALOT more organised enjoy guys .Last edited by rubendodge : 05-27-08 at 03:09 PM. |
|
|
|
|
|
#30 (permalink) |
|
New to Overclock.net
|
You don't have to 'restart' the program - you need to wrap the innards of the program in a loop. C++ has 3 loop structures - for this style you would probably want to use a do..while loop because you want to present options and get input at least once then test the loop condition at the 'end': i.e.
Code:
{
//snippet
const int ExitCode = -1;
const int NumMainMenuOpts = 6;
do
{
display_base_menu_opts();
// limit possible input values from 1..6
menuchoice = read_valid_key_input(NumMainMenuOpts);
switch(menuchoice)
{
case 1: do_stuff();
break;
case 2: do_more_stuff();
break;
case 3..5: // etc.
case 6: menuchoice = ExitCode; // assign 'impossible to reach' value
break;
default: cout << "unhandled menu option error" << endl;
break;
};
}while (menuchoice != ExitCode);
//clean up and exit
}
'do_stuff()' and 'do_more_stuff()' are not good names btw - they're just placeholders ![]() |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|