Game between the two students studying quadratic equation solution.
1.In each round the first student gives his friend to solve a quadratic equation he writes. The other student has to solve a quadratic equation. if he is right he gets right to the point. At this second student gives the student first quadratic he writes, and the first student solves the equation, and if he's right he gets right to the point.
2.First step of the game is three rounds. if one of students have more credit is the winner.
3 if the first stage ended in a tie, continue adding rounds until one of the students gets a point and the other does not get the point, and the student who get the point is wins.
• In every round told what number round it.
• In every round Outputs points per player.///have a problem!!!! In every new round points are reset. And the function void Obs_Winner(int,int) does not get correct results for comparison.
• ……..
//this is code
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
void CreatingOfTheEquation(int,int,int);//the f. printing of equation
int Player_answer();//f.player answer
bool good_solution(int a,int b,int c);//f.of solution (no solution)
bool good_solution_x1(int a,int b,int c);//f.of solution (one solutio)
bool good_solution_x1_x2(int a,int b,int c);//f.of solution (two solutions)
void game(int Points_player1,int Points_player2);////one cyrcle of game
void Obs_Winner(int,int);//f.winner of game(3 cycles)
int main()
{
int continuePlay=1;
int Points_player1=0;
int Points_player2=0;
cout<<"Wellcome to Quadratic Equation Game!!! "<<endl<<endl;
cout<<"Player1: "<<0<<" points"<<endl;
cout<<"Player2: "<<0<<" points"<<endl<<endl;
while(continuePlay<4)//in the game 3 rounds
{
cout<<"Round Number="<<continuePlay<<endl<<endl;
game(Points_player1,Points_player2);////one cyrcle of game
continuePlay++;
}
cout<<"helpforme point1 ; "<<Points_player1<<" helpforme point1; "<<Points_player1<<endl;
Obs_Winner(Points_player1,Points_player2);//f.winner of game(3 cycles)
return 0;
}
void game(int Points_player1,int Points_player2)//one round of the game
{
int playerAnswer;
int player_num=1;
int a, b, c;
double x1,x2;
do
{//first cycle for player2 answer,second for player2 answer
// player input parametres of Equation
cout<<"Player "<<player_num<<",pleas,enter values: a,b and c: " << endl;
cout << "a: ";
cin >> a;
cout << "b: ";
cin >> b;
cout << "c: ";
cin >> c;
x1 = (-b +sqrt((b*b) -4*a*c))/2*a;
x2 = (-b -sqrt((b*b) -4*a*c))/2*a;
CreatingOfTheEquation(a,b,c);//the f. printing of equation
if(player_num==1)
{//if input parametres from player1,player2 choos answer
cout<<"Plaer "<<player_num+1<<",choos solution:"<<endl<<"1.two"<<endl<<"2.one"<<endl<<"3.no"<<endl;
playerAnswer=Player_answer();
cout<<"Your answer is: "<<playerAnswer<<endl;
}
if(player_num==2)
{//if input parametres from player2,player1 choos answer
cout<<"Plaer "<<player_num-1<<",choos solution:"<<endl<<"1.two"<<endl<<"2.one"<<endl<<"3.no"<<endl;
playerAnswer=Player_answer();
cout<<"Your answer is: "<<playerAnswer<<endl<<endl;
}
int winner;
if(playerAnswer==1 && good_solution_x1_x2(a,b,c))//if player have good solution(two solutions)
{
winner=1;
cout<<"good!!and x1= "<<x1<<"and x2= "<<x2<<endl<<endl;
}
else if(playerAnswer==2 && good_solution_x1(a,b,c))//if player have good solution(one solution)
{
winner=1;
cout<<"good!!and x= "<<x1<<endl<<endl;
}
else if (playerAnswer==3 && good_solution(a,b,c))//if player have good solution(no solution)
{
winner=1;
cout<<"good!!"<<endl<<endl;
}
else//if player don't have good solution
{
winner=0;
cout<<"baaad!!!"<<endl;
}
if(winner==1) //the player who have good solution must to take +1 point
{
if(player_num==1)Points_player2=Points_player2+1;
if(player_num==2) Points_player1=Points_player1+1;
}
player_num++;
}while(player_num<=2);
cout<<"***********************************************************"<<endl<<endl;
//after round must to print the players point ++ of all round ,it's not work
cout<<"Player1: "<<Points_player1<<" points"<<endl;
cout<<"Player2: "<<Points_player2<<" points"<<endl<<endl;
}
void Obs_Winner(int Points_player1,int Points_player2)
{
do{//winner of full game + tiko