Hi! This is my first (and last) computer science class and I am SO lost. We're suppose to copy and paste this into C++ and fix all the errors and run it. If it runs, we pass and if it doesnt, we fail. I have been sitting here for 4 hours trying to fix the errors but each one i fix, the line above it turns red and I have no idea what i am doing.... Here is the assignment. If anyone can tell me what im doing wrong, I would appreciate it!
/* CSCI 1205: Homework #1
* Student ID: __________________ */
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int secret_number, guess, count;
cout << "Let's play a guessing game!" << endl << endl;
cout << "I'll pick a number from 0 to 9, inclusive." << endl;
cout << "You have up to 9 tries to guess it." << endl;
cout << "Good luck!" << endl << endl;
// rand() returns an integer between 0 and RAND_MAX
// we use modulo, to reduce the scale to 0 .. 9
secret_number = rand() % 10;
count = 0;
do {
if ( count )
cout << "Sorry, that's not it!" << endl;
cout << "Enter your guess: ";
cin >> guess;
} while ( guess != secret_number ) && ( ++count < 9 ) );
// we need this b/c of the "short-circuit" boolean expression
count++;
// we want some space between the guessing and the final result
cout << endl;
if ( guess == secret_number )
{
cout << "You got it in " << count << " guesses!" < endl;
cout << "Good work!" << endl;
}
else
{
cout << "Sorry, you used up all your guesses!" << endl;
cout << "The secret number was: " << secret_number << endl;
cout << "Better luck next time!" << endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
// END of Homework #0
#include <iostream>
#include <cstdlib>
usingnamespace std;
int main(int argc, char *argv[])
{
int secret_number, guess, count;
cout << "Let's play a guessing game!" << endl << endl;
cout << "I'll pick a number from 0 to 9, inclusive." << endl;
cout << "You have up to 9 tries to guess it." << endl;
cout << "Good luck!" << endl << endl;
// rand() returns an integer between 0 and RAND_MAX
// we use modulo, to reduce the scale to 0 .. 9
secret_number = rand() % 10;
count = 0;
do {
if ( count )
cout << "Sorry, that's not it!" << endl;
cout << "Enter your guess: ";
cin >> guess;
} while (( guess != secret_number ) && ( ++count < 9 ));
// we need this b/c of the "short-circuit" boolean expression
count++;
// we want some space between the guessing and the final result
cout << endl;
if(guess == secret_number)
{
cout << "You got it in " << count << " guesses!" < endl;
cout << "Good work!" << endl;
}
else
{
cout << "Sorry, you used up all your guesses!" << endl;
cout << "The secret number was: " << secret_number << endl;
cout << "Better luck next time!" << endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
int main(int argc, char *argv[])
{
int secret_number, guess, count;
cout << "Let's play a guessing game!" << endl << endl;
cout << "I'll pick a number from 0 to 9, inclusive." << endl;
cout << "You have up to 9 tries to guess it." << endl;
cout << "Good luck!" << endl << endl;
// rand() returns an integer between 0 and RAND_MAX
// we use modulo, to reduce the scale to 0 .. 9
secret_number = rand() % 10;
count = 0;
do
{
if ( count )
cout << "Sorry, that's not it!" << endl;
cout << "Enter your guess: ";
cin >> guess;
} while (( guess != secret_number ) && ( ++count < 9 ));
// we need this b/c of the "short-circuit" boolean expression
count++;
// we want some space between the guessing and the final result
cout << endl;
if(guess == secret_number)
{
cout << "You got it in " << count << " guesses!" << endl;
cout << "Good work!" << endl;
}
else
{
cout << "Sorry, you used up all your guesses!" << endl;
cout << "The secret number was: " << secret_number << endl;
cout << "Better luck next time!" << endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
#include <iostream>
#include <cstdlib>
usingnamespace std;
int main(int argc, char *argv[])
{
int secret_number, guess, count;
cout << "Let's play a guessing game!" << endl << endl;
cout << "I'll pick a number from 0 to 9, inclusive." << endl;
cout << "You have up to 9 tries to guess it." << endl;
cout << "Good luck!" << endl << endl;
// rand() returns an integer between 0 and RAND_MAX
// we use modulo, to reduce the scale to 0 .. 9
secret_number = rand() % 10;
count = 0;
do {
if ( count )
cout << "Sorry, that's not it!" << endl;
cout << "Enter your guess: ";
cin >> guess;
} while (( guess != secret_number ) && ( ++count < 9 ));
// we need this b/c of the "short-circuit" boolean expression
count++;
// we want some space between the guessing and the final result
cout << endl;
if(guess == secret_number)
{
cout << "You got it in " << count << " guesses!" << endl;
cout << "Good work!" << endl;
}
else
{
cout << "Sorry, you used up all your guesses!" << endl;
cout << "The secret number was: " << secret_number << endl;
cout << "Better luck next time!" << endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}