### HELP, Stuck on this

 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576`` ``````#include #include #include using namespace std; int main() { double g; //generator's nameplates double s; //average wind speed double w; //watts int i=0; // repeat //Intro message cout << "Greetings, we will be calculation watts per mile per hour\n"; //Collecting info while (i==0) { cout << "Insert Generator's name capacity in watts\n"; cin >> g; { if (g < 300) { cout << "Nameplate capacity must be between 300 and 8,000,000 watts.\n"; } else if (g > 8,000,000) { cout << "Nameplate capacity must be less than 8,000,000.\n"; } else { break; } } } while (i==0) { cout << "Insert today's average daily wind speed\n"; cin >> s; if (s < 0) { cout << "Wind speed must be greater than zero.\n"; } else if ((s >= 0) && (s < 6)) { cout << "Wind speed is not sufficient to power the generator.\n"; } else if ((s >= 39) && (s <= 73)) { cout << "Tropical storm wind speeds. Wind turbine not operating.\n"; } else if (s > 73) { cout << "Time to buy a new wind turbine.\n"; } else { break; } } w = g*(s/28)*(s/28)*(s/28); if(w < 1000) { printf("Your windmill generated" %.1f " watts today!", w); } else if((w > 1000) && (w < 1000000)) { w = w/1000; printf("Your windmill generated" %.1f " watts today!", w); } else if(w > 1000000) { w = w/1000000; printf("Your windmill generated" %.1f " watts today!", w); } } ``````

I don't see what's wrong with it. It keeps reprompting on the second while loop even though I don't want it to reprompt, just go back to nameplate capactity prompt. Let me know if you see what my problems are and ask me if you need any clarification.
Last edited on
Looks like you have an infinite loop.
 ``123`` ``````int i=0; ... while (i==0)``````

The variable i never changes from being 0.

Also.
 ``12345678910111213141516`` ``````cout << "Insert Generator's name capacity in watts\n"; cin >> g; { <- //What purpose do these two braces serve? if (g < 300) { cout << "Nameplate capacity must be between 300 and 8,000,000 watts.\n"; } else if (g > 8,000,000) { cout << "Nameplate capacity must be less than 8,000,000.\n"; } else { break; } } <- //What purpose do these two braces serve? ``````
Last edited on
Topic archived. No new replies allowed.