Okay, so I am having a few problems with my computer science lab. Below is what I have so far. I am almost positive that the equations are correct, but for some reason I keep getting a different answer than the cs labs example program. So obviously something is wrong. Could you please help me find the problem and solve it?
My imput for my program and the example program has been this.
N
2H
Y
10
Now the difference is that my output is this.
2 H by North, making 10 for 280 points
And the example programs output is this.
2 H by North, making 4 for 170 points
#include <iostream>
#include <string>
using namespace std;
bool isGame (int, string);
int main()
{
string trump;
int score, contract, numTricks;
char winner, vuln;
bool win = true;
cout << "Who won the bidding? " "(N/S/E/W): ";
cin >> winner;
if(winner!='N' && winner!='S' && winner!='E'&& winner !='W')
{
cout << "Directions must be N, S, E, or W.\n";
return 0;
}
cout << "What won the contract? " "(Such as 2 H or 3 NT): ";
cin >> contract;
cin >> trump;
if (trump!="NT" && trump!="S" && trump!="A" && trump!="D" && trump!="H"){
cout << "The contract's suit must be NT, S, H, D or A.\n";
return 0;
}
if(contract > 7||contract < 1){
cout << "Contract is wrong.\n";
return 0;
}
cout << "Was the partnership vulnerable? (Y/N): ";
cin >> vuln;
if(vuln != 'Y' && vuln != 'N'){
cout << "Vulnerability must be Y or N.";
return 0;
}
//check if we won enough tricks
cout << "How many tricks were taken? ";
cin >> numTricks;
if((contract+6) > numTricks)
{
win = false; // we lost so update our win boolean
if (vuln == 'Y')
{
score= -100*((contract+6)-numTricks);// do calculations for this case
}
else
{
score= -50*((contract+6)-numTricks);// do calcs for no case
}
}
else // we won calculate score for winning
{
if (vuln == 'N')
{
score= 20*(numTricks-6);
}
else (trump == "S" || trump == "H"|| trump == "A" || trump == "D");{//Won Enough)
score= 30*(numTricks-6);
}
if (trump=="NT");{
score=20*((numTricks-6)+(10));
}
}
cout << contract << " " << trump << " by";
if ( winner == 'N') {cout << " North, ";}
if ( winner == 'S') {cout << " South, ";}
if ( winner == 'W') {cout << " West, ";}
if ( winner == 'E') {cout << " East, ";}
if (win)
{
cout << "making";
}
else
{
cout << " down";
}
cout << " " << numTricks <<" for" << " " << score << " " << "points\n";
return 0;
}