C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 24th, 2013, 10:07 AM
alonaioffe alonaioffe is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2013
Posts: 1 alonaioffe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 18 sec
Reputation Power: 0
Syntax errors - Pleeeeeaaaase,i need help

hello,i have a problem in my home work code:
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 aproblem!!!! In every new round points are reset. And the function void Obs_Winner(int,int) does not get correct results for comparison.
..
it's my 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(int a,int b,int c, double x1);
//f.of solution (one solutio)
bool good_solution(int a,int b,int c, double x1, doublex2);
//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)

void 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++;
}

Obs_Winne(Points_player1,Points_player2);
//f.winner of game(3 cycles)
}

void CreatingOfTheEquation(int a,int b,int c)
//the f. printing of equation
{
cout<<"The Quadratic Equation is : ";
if(a!=0)
{
if(b>0 && c>0)
{
cout<<a<<"x^2+"<<b<<"x+"<<c<<" = 0"<<endl<<endl;
}
else if(b<0 && c>0)
{
cout<<a<<"x^2 "<<b<<"x+"<<c<<"= 0"<<endl<<endl;
}
else if(b<0 && c<0)
{
cout<<a<<"x^2 "<<b<<"x "<<c<<"= 0"<<endl<<endl;
}
else if(b>0 && c<0)
{
cout<<a<<"x^2+"<<b<<"x "<<c<<"= 0"<<endl<<endl;
}
else if(b<0 && c==0)
{
cout<<a<<"x^2 "<<b<<"x"<<"= 0"<<endl<<endl;
}
else if(b>0 && c==0)
{
cout<<a<<"x^2+"<<b<<"x"<<"= 0"<<endl<<endl;
}
else if(b==0 && c<0)
{
cout<<a<<"x^2 "<<c<<"= 0"<<endl<<endl;
}
else if(b=0 && c>0)
{
cout<<a<<"x^2+"<<c<<" = 0"<<endl<<endl;
}
else
{
cout<<a<<"x^2=0"<<endl<<endl;
}
}
else
{
cout<<"It's not Quadratic Equation!Try again..."<<endl<<endl;
}

}

int Player_answer()//f.player answer
{
int answer;
cin>>answer;
return answer;
}

bool good_solution(int a,int b,int c)
//f.of solution
{
return ((b*b-4*a*c) <0);
}
bool good_solution(int a,int b,int c, double x1)
//f.of solution
{
return ((b*b-4*a*c) ==0);
}
bool good_solution(int a,int b,int c, double x1, double x2)
//f.of solution
{
return ((b*b-4*a*c) >0);
}

void game(int Points_player1,int Points_player2)
//one round of the game
{
int playerAnswer;
int playerAnswer1;
int playerAnswer2;
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();
playerAnswer2=playerAnswer;
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();
playerAnswer1=playerAnswer;
cout<<"Your answer is: "<<playerAnswer<<endl<<endl;
}
int winner;
if(playerAnswer==1 && good_solution(a,b,c,x1,x2))//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(a,b,c,x1))//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_player1=Points_player1+1;
if(player_num==2) Points_player2=Points_player2+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
if(Points_player1<Points_player2)//winner of full game(not TIko)
{
cout<<"!!!!!!!!THE WINNER IS PLAYER2!!!!!!!!"<<endl;
}
if(Points_player1>Points_player2)
{
cout<<"!!!!!!!!THE WINNER IS PLAYER1!!!!!!!!"<<endl;
}
if(Points_player1==Points_player2)
{
cout<<"THE TIKO Round!!!!"<<endl<<endl;
game(Points_player1,Points_player2);//tiko raund
if(Points_player1<Points_player2)
{
cout<<"!!!!!!!!THE WINNER in TIKO IS PLAYER2!!!!!!!!"<<endl;
}
if(Points_player1>Points_player2)
{
cout<<"!!!!!!!!THE WINNER in TIKO IS PLAYER1!!!!!!!!"<<endl;
}
}
Points_player1++;

}while(Points_player1==Points_player2);//tiko circulation
}

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Syntax errors - Pleeeeeaaaase,i need help


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap