SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 3 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 14 Nov 2017 My Price 8.00

function returning a winner after I coded the rock scissors

I am having problems with my function returning a winner after I coded the rock scissors and paper function play.   I need to complete it ASAP. Thank you.

 

#include <iostream>

#include <string>

using namespace std;

void play (int winner) {

 string p1, p2;

 

  if ((p1 == "paper") || (p2 == "rock")){

  return 1; }

    

  else if ((p1 == "rock") || (p2 == "scissors")){

     return 1; }

  

  else if ((p1 == "scissors") || (p2 == "paper")){

     return 1;

  }

}

int main()

{

 string p1, p2;

 cout << "Play rock, paper, scissorsn";

 string goOn = "yes";

 while (goOn == "yes") {

  cout << "Player 1: ";

  cin >> p1;

  cout << p1 << endl;

  cout << "Player 2: ";

  cin >> p2;

  cout << p2 << endl;

  int winner = play(p1, p2);

  if (winner == 0)

    cout << "Draw!" << endl;

  else if (winner == 1)

    cout << "Player 1 wins!" << endl;

  else if (winner == 2)

    cout << "Player 2 wins!" << endl;

  else

    cout << "ACK! SOMETHING IS WRONG!" << endl;

  cout << "Do you want to continue? (yes or no): ";

  cin >> goOn;

  cout << goOn << endl;

 }

}

 

I get these compile errors if it helps ...

main.cpp: In function 'void play(int)':

main.cpp:10:11: error: return-statement with a value, in function returning 'void' [-fpermissive]

   return 1; }

          ^

main.cpp:13:14: error: return-statement with a value, in function returning 'void' [-fpermissive]

      return 1; }

             ^

main.cpp:16:14: error: return-statement with a value, in function returning 'void' [-fpermissive]

      return 1;

             ^

main.cpp: In function 'int main()':

main.cpp:32:27: error: cannot convert 'std::__cxx11::string {aka std::__cxx11::basic_string<char>}' to 'int' for argument '1' to 'void play(int)'

  int winner = play(p1, p2);

Answers

(5)
Status NEW Posted 14 Nov 2017 07:11 AM My Price 8.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)