What can i do to further my studies because idon't have mone

All the non Calibra related waffle and jokes. Not for excessive spamming

What can i do to further my studies because idon't have mone

by ginstt » Fri Sep 23, 2011 5:47 pm

I need to write a program where the user has to guess the random number that the program makes up. The range is between 0 - 100 and the user only gets 10 tries to guess the number. If the number is too high or too low, it informs the user by saying that the random number is lower or higher.

I'm still learning Java and C++ is very new to me, even though most of the stuff is similar. The program that I have written compiles and runs, but it doesn't seem to reach the steps that tell the user whether the number the entered is higher or lower than the random number. This is my first time using nested if's and I probably have them ordered in a way where they aren't being read.

Can anyone point me in the right direction so my program will follow through with the right step at the right time?

Here is my code:

#include <iostream>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>

int main ()

int usersGuess;
int usersChances = 0;
int secretInt;

int MAX_VALUE = 100 + 1;
int MIN_VALUE = 0;

srand ( time(NULL) );

secretInt = rand() % 100 + 1;

while ( (usersGuess != secretInt) && (usersChances <= 9) )

cout << "The secret number is between 1 and 100.\n"
<< "What is your guess? ";
cin >> usersGuess;

usersChances++;

if ( usersGuess > MAX_VALUE && usersGuess > MIN_VALUE )

if ( usersGuess == secretInt )

cout << "Right! It took you " << usersChances << " guesses.";
break;

if ( usersGuess < secretInt )

cout << "Too low, guess again? ";
usersChances++;

if ( usersGuess > secretInt )

cout << "Too high, guess again? ";
usersChances++;

cout << "Invalid guess, guess again? ";




Tips or suggestions are greatly appreciated. Thank you!
ginstt
 

Re: What can i do to further my studies because idon't have

by Robs-se » Fri Sep 23, 2011 9:02 pm

What engine does it have??
Nothing succeeds like a budgie with nae teeth

Up the Hibs!!

Now with added Vectra VXR power

Now calibraless
User avatar
ClubCalibra.net
ClubCalibra.net
 
Posts: 1320
Joined: Thu Apr 08, 2004 8:55 pm
Location: Luton

Re: What can i do to further my studies because idon't have

by big_gordy » Sat Sep 24, 2011 8:40 am

ohhhh i hated c++ in collage passed it though and still dont understand it lol

why c++ that bow on old language?
Best Presented Billing 2007 Green V6 Auto

SE9 V6 Duel Fuel LPG aka THE RED DEVIL
Tigra Chequers 1.6 - # 2 Car
User avatar
ClubCalibra.net
ClubCalibra.net
 
Posts: 1431
Joined: Sun Feb 08, 2004 1:00 pm
Location: Johnstone Now Sydney in Oz


Who is online
Users browsing this forum: No registered users and 17 guests