Connecting Tech Pros Worldwide Forums | Help | Site Map

Help help!!

Newbie
 
Join Date: Oct 2009
Posts: 3
#1: 4 Weeks Ago
Write a program that asks the user for a number between 1 and 10, then prints a line of that many “X”s
as shown below. Reject any entries outside of the range of 1 to 10 by displaying “Entry is out of range.”
You must use a FOR LOOP for this problem. The variable used to store the number of Xs must be called
“numExs”.

please help
thanks Jon

Moderator
 
Join Date: Mar 2007
Location: North Bend Washington USA
Posts: 5,382
#2: 4 Weeks Ago

re: Help help!!


I can't do your code for you.

Exactly what is your problem?

I suggest you break things down into steps:

1) get the number
2) display an X
3) use the number to do step 2 as many times as needed
Newbie
 
Join Date: Oct 2009
Posts: 3
#3: 4 Weeks Ago

re: Help help!!


for example the program asks the user to enter a number ( 1 - 10 )
the user types in lets say 6
it would then displays
XXXXXX

trying to figure out how to get this to work and I do not want to just hard code it by using if statements if number == 1 then cout << "X" if number == 2 cout << "XX" and so on and so on
Expert
 
Join Date: Mar 2008
Location: Naperville, Illinois U.S.
Posts: 831
#4: 4 Weeks Ago

re: Help help!!


Quote:

Originally Posted by laukhuff66 View Post

trying to figure out how to get this to work and I do not want to just hard code it by using if statements if number == 1 then cout << "X" if number == 2 cout << "XX" and so on and so on

What do you have so far?
Newbie
 
Join Date: Oct 2009
Posts: 3
#5: 4 Weeks Ago

re: Help help!!


/*Jon F. Laukhuff
CMPSCI 101
Section 1*/

#include <iostream>
#include <string>
using namespace std;

//Write a program that asks the user for a number between 1 and 10, then prints a line of that many “X”s
//as shown below. Reject any entries outside of the range of 1 to 10 by displaying “Entry is out of range.”
//You must use a FOR LOOP for this problem. The variable used to store the number of Xs must be called
//“numExs”.

{
int numExs;
cout << "Please enter the number of Xs (1-10): ";
cin >> numExs;
if ((numExs < 0 ) || (numExs > 10))
{
cout << "Entry is out of range"<< endl;
}
else
{

}




}
Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,195
#6: 4 Weeks Ago

re: Help help!!


That is clearly not a compilable program, for starters it has no main, also your question instructs you to use a for loop, therefore I suggest you start by reading up on

main function
for loops
Newbie
 
Join Date: Oct 2009
Posts: 9
#7: 4 Weeks Ago

re: Help help!!


In this site, you don't as a question titled "Help Help!!"
You ask it titled "F1 F1!!"
It's computer language.
Newbie
 
Join Date: Oct 2009
Posts: 9
#8: 4 Weeks Ago

re: Help help!!


Okay I won't "spoonfeed", but I'll give you the C code for it, and you can try figuring out the C++ code from it.

Expand|Select|Wrap|Line Numbers
  1. deleted by weaknessforcats. Reason: spoonfeeding.
Reply