I need help to display on the screen rock when user picks rock, paper when user picks paper, and scissors when user picks scissors. Thanks

graphics.h was a header file released with some compilers back in the eighties and early nineties (i.e. twenty years ago) that enabled a programmer to use a very custom library (also provided wit hthat compiler) to show simple graphics on the systems of the day.

Are you programming for MSDOS in the year 1990? I bet you're using Turbo C++ from twenty years ago too. If you're learning, using twenty year old tools is a bad idea.

If you're using a modern computer, you should consider moving to a modern compiler and a modern IDE. You can still use a header named graphics.h because people have rewritten it repeatedly over the decades for modern computers, but there are also more modern options available for drawing lines.

Our professor told us to use that header, but really, he didn't teach us anything about it yet he insists we make a program displaying rock, paper, or scissors. Can you please explain a little bit how it works or give an example code of (for example, scissors) Thanks a lot!

Our professor told us to use that header, but really, he didn't teach us anything about it yet he insists we make a program displaying rock, paper, or scissors. Can you please explain a little bit how it works or give an example code of (for example, scissors) Thanks a lot!

You could use a 'Table Look Up' method ...

I need help to display on the screen rock when user picks rock, paper when user picks paper, and scissors when user picks scissors. Thanks

// define table ...
const char* CHOICES[] = { "ROCK", "PAPER", "SCISSORS" };

// function prototype ...
int takeInValidIntInRange( const char* prompt, int min, int max );


// in main ...

cout << "Choices are ";
for( int i = 0; i < 3; ++ i ) cout << "(" << (i+1) << ") " << CHOICES[i] << " ";
cout << endl;

int choice = takeInValidIntInRange( "Enter an integer in the range 1..3: ", 1, 3 );

cout << "Your choice was: " << CHOICES[choice-1] << endl;

I'm sorry for the misunderstanding. I want to 'display' or depict the image of a rock when user picks rock, scissors when scissors, and paper when user picks paper.

I am going to give you the same advice I give all the students who come here whose professors' are requring them to use Turbo C++ for current-day coursework:

  • Stand up in class, explain to your fellow students that the professor is teaching out-of-date and useless information that will hinder your ability to work in programming in the future,
  • Walk out of the course and encourage as many other classmates as you can to do so as well,
  • Go to the Dean's office and petition for the professor to be removed on the grounds of incompetence.

There is absolutely no justification for using Turbo C++ in an era when it won't even run on most new systems. Modern, powerful and effective compilers and IDEs which support modern versions of the language and present-day programming techniques are freely available from multiple sources, including Microsoft. To still be using and teaching a compiler that is older than most of the students using it is nothing short of criminal.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.