int main(int argc, char** argv) {
//declare variables
int a,b,c,d,e;
float min_num = 5,max_num = 25;
cout<<"please enter a number between 5-25"<<endl;
cin>>a;
cin>>b;
cin>>c;
cin>>d;
cin>>e;
while(a < min_num || a > max_num){
cout<<"I SAID BETWEEN"<<min_num<<"and"<<max_num<<endl;
cout<<"please enter a number between 5-25"<<endl;
cin>>a;
cin>>b;
cin>>c;
cin>>d;
cin>>e;
}
while(b < min_num || b > max_num){
cout<<"I SAID BETWEEN"<<min_num<<"and"<<max_num<<endl;
cout<<"please enter a number between 5-25"<<endl;
cin>>a;
cin>>b;
cin>>c;
cin>>d;
cin>>e;
}
while(c < min_num || c > max_num){
cout<<"I SAID BETWEEN"<<min_num<<"and"<<max_num<<endl;
cout<<"please enter a number between 5-25"<<endl;
cin>>a;
cin>>b;
cin>>c;
cin>>d;
cin>>e;
}
while(d < min_num || d > max_num){
cout<<"I SAID BETWEEN"<<min_num<<"and"<<max_num<<endl;
cout<<"please enter a number between 5-25"<<endl;
cin>>a;
cin>>b;
cin>>c;
cin>>d;
cin>>e;
}
while(e < min_num || e > max_num){
cout<<"I SAID BETWEEN"<<min_num<<"and"<<max_num<<endl;
cout<<"please enter a number between 5-25"<<endl;
cin>>a;
cin>>b;
cin>>c;
cin>>d;
cin>>e;
}
return 0;
}
You are trying to get input into 5 integers. You want to make sure that input is between 5 and 25. I suggest the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int main()
{
int a,b,c,d,e;
constint min_num = 5, max_num = 6; //Don't know why you used float, the input can only be int
cout << "Please enter five numbers between " << min_num << " and " << max_num << ". Thank you.\n";
while(!cin >> a && a >= min_num && a <= max_num)
{
cout << "Please enter a number between "<< min_num << " and " << max_num << ". Thank you.\n"; //Try to be more polite. Rudeness will only turn away users.
cin.clear();
cin.sync();
}
//continue in the same way, only substituting a for b and c and so on.
//draw the asterisks
return 0;
}
i need to have a loop on it so if they dont enter 5-25 and u say draw the asterisks but i need it so if they enter a 10 there will be 10 asterisks.
this is the problem (One interesting application of computers is drawing graphs and
bar charts (sometimes called "histograms"). Write an application that
reads up to 5 numbers (each between 5 and 25). For each number entered,
your program should draw a line containing that number of adjacent
asterisks. For example, if your program reads the number seven, it
should print *******.) my teacher said there needs to be a loop