• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

HELP With C++ PROGRAM ASAP PLEASE

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

ramiealawi

New Member
Joined
Mar 21, 2009
hey guys i have to write this C++program i am a beginner but i am very confuse i have to

Write a program that asks the user to enter his/her full name. The full name (including spaces) must be stored in a single string. Declare the string with a maximum of 40 characters.

- Calculate the number of characters (L) in the string holding the full name and generate a random number (target) between 1 and L (remember to seed the random number generator with the current CPU time).

- Send these numbers (L and target) as input parameters to a function called Guess.

- Inside the function Guess ask the user to guess the target number. If the user enters a number out of the range (smaller than 1 or larger than L), notify so and ask for the number again.

- Once the user enters a valid number (within the range), compare it to the target number and return a value of 0 to the main function if the user guessed incorrectly or return a value of 1 to the main function if the user guessed correctly.

- Back in the main function, use the returned value from the function Guess to notify the user whether the guess was correct or incorrect.

- Give the user three (3) chances to guess the target number
this i was i got so far


#include <iostream>
#include <string>

using namespace std;

int main()
{
int userName;
int userGuess;

cout <<"Enter you full name: ";
cin >> userName;

cout <<"Enter and guess between 1 and 15:"<<userGuess<<"\n";
cin >>userGuess;

if ((userGuess < 1) || (userGuess > 15))
{
cout << "Your guess is out of the range, try again...\n\n";
cout << "Another chance...\n";
}
}
 
No offense but this seems like very intro level C++ which is something that any aspiring programmer should be able to accomplish with relative ease... While I am familiar with C++ I am not currently applying my talents and I would have to look at a few references to answer your questions. In other words, go look through your text book.

http://www.cplusplus.com/reference/string/string/ is also a good resource, but not as good as javadocs unfortunately.

If you can't wrap your head around the material then I would suggest finding a peer, teaching assistant, tutor, or professor. I don't think anyone here wants to do your work for you. On the other hand if you can give a specific example of something that is not working for you then we might be able to assist as ShadowPho was getting at.

btw, :welcome:
 
Back