#include<iostream>
#include<stdlib.h>
#include<stdio.h>
usingnamespace 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";
}
elseif (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";
}
elseif ((s >= 0) && (s < 6))
{
cout << "Wind speed is not sufficient to power the generator.\n";
}
elseif ((s >= 39) && (s <= 73))
{
cout << "Tropical storm wind speeds. Wind turbine not operating.\n";
}
elseif (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);
}
elseif((w > 1000) && (w < 1000000))
{
w = w/1000;
printf("Your windmill generated" %.1f " watts today!", w);
}
elseif(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.
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";
}
elseif (g > 8,000,000)
{
cout << "Nameplate capacity must be less than 8,000,000.\n";
}
else
{
break;
}
} <- //What purpose do these two braces serve?