Im new to coding and this is my assignment, my question is why both of the if else segment doesn't count out when I run the program.
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int state, vote = 0, sabah = 0, sarawak = 0, labuan = 0, packageA = 0, packageB = 0;
char package, select;
cout << "The Recreation Club, Kampus Kuala Terengganu\n\n"
"Given the following states:\n"
"[1] SABAH\n"
"[2] SARAWAK\n"
"[3] LABUAN\n\n"
"Choose the state you prefer to go (1/2/3): ";
cin >> state;
if (state == 1)
vote++, sabah++;
else if (state == 2)
vote++, sarawak++;
else if (state == 3)
vote++, labuan++;
cout << "\nPACKAGE REMARK COST (RM) PER PAX\n"
"A Inclusive all 1600\n"
"B Exclusive food 899\n\n"
"Choose your package: ";
cin >> package;
if (package == 'A' || package == 'a')
packageA++;
else if (package == 'B' || package == 'b')
packageB++;
cout << "\nContinue with the next person (Y/N): ";
cin >> select;
while (select != 'N' && select != 'n')
{
cout << "\n[1] SABAH\n"
"[2] SARAWAK\n"
"[3] LABUAN\n\n"
"\nChoose the state you prefer to go (1/2/3): ";
cin >> state;
if (state == 1)
vote++, sabah++;
else if (state == 2)
vote++, sarawak++;
else if (state == 3)
vote++, labuan++;
cout << "\nPACKAGE REMARK COST (RM) PER PAX\n"
"A Inclusive all 1600\n"
"B Exclusive food 899\n\n"
"\nChoose your package: ";
cin >> package;
if (package == 'A' || package == 'a')
packageA++;
else if (package == 'B' || package == 'b')
packageB++;
cout << "\nContinue with the next person (Y/N): ";
cin >> select;
}
cout << "\nThe ranking summary\n"
"--------------------\n"
"Number of voters: " <<vote<< "";
{
if ((sabah >> sarawak && sarawak >> labuan) || (sabah >> sarawak && sarawak == labuan))
cout << "\n\nFirst choice : Sabah (voted by " <<sabah<< " people)\n"
"Second choice : Sarawak (voted by " <<sarawak<< " people)\n"
"Third choice: Labuan (voted by " <<labuan<< " people)\n\n";
else if (sabah >> labuan && labuan >> sarawak)
cout << "\n\nFirst choice : Sabah (voted by " <<sabah<< " people)\n"
"Second choice : Labuan (voted by " <<labuan<< " people)\n"
"Third choice: Sarawak (voted by " <<sarawak<< " people)\n\n";
else if ((sarawak >> sabah && sabah >> labuan) || (sarawak >> sabah && sabah == labuan))
cout << "\n\nFirst choice : Sarawak (voted by " <<sarawak<< " people)\n"
"Second choice : Sabah (voted by " <<sabah<< " people)\n"
"Third choice: Labuan (voted by " <<labuan<< " people)\n\n";
else if (sarawak >> labuan && labuan >> sabah)
cout << "\n\nFirst choice : Sarawak (voted by " <<sarawak<< " people)\n"
"Second choice : Labuan (voted by " <<labuan<< " people)\n"
"Third choice: Sabah (voted by " <<sabah<< " people)\n\n";
else if ((labuan >> sabah && sabah >> sarawak) || (labuan >> sabah && sabah == sarawak))
cout << "\n\nFirst choice : Labuan (voted by " <<labuan<< " people)\n"
"Second choice : Sabah (voted by " <<sabah<< " people)\n"
"Third choice: Sarawak (voted by " <<sarawak<< " people)\n\n";
else if (labuan >> sarawak && sarawak >> sabah)
cout << "\n\nFirst choice : Labuan (voted by " <<labuan<< " people)\n"
"Second choice : Sarawak (voted by " <<sarawak<< " people)\n"
"Third choice: Sabah (voted by " <<sabah<< " people)\n\n";
else if ((sabah == sarawak && sabah >> labuan) || (sabah == labuan && sabah >> sarawak) || (labuan == sarawak && labuan >> sabah))
cout << "\n\nThere is a draw for first choice. Please redo the vote.\n\n";
}
cout << "Package Preference\n"
"--------------------\n"
"Package A: Preferred by " <<packageA<< " people\n"
"Package B: Preferred by " <<packageB<< " people";
{
if (packageA >= 10 && packageA >> packageB)
cout << "\n\nA group discount of 10% is applicable for Package A. The cost per person for Package A is now RM1440.\n\n";
else if (packageA << 10 && packageA >> packageB)
cout << "\n\nThe cost per person for Package A is RM1600.\n\n";
else if (packageB >= 10 && packageB >> packageA)
cout << "\n\nA group discount of 10% is applicable for Package B. The cost per person for Package B is now RM809.10.\n\n";
else if (packageB << 10 && packageB >> packageA)
cout << "\n\nThe cost per person for Package B is RM899.\n\n";
else if (packageA == packageB)
cout << "\n\nThere is a draw in the voting. Please redo the vote.\n\n";
}
system ("pause");
return 0;
}
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int state, vote = 0, sabah = 0, sarawak = 0, labuan = 0, packageA = 0, packageB = 0;
char package, select;
cout << "The Recreation Club, Kampus Kuala Terengganu\n\n"
"Given the following states:\n"
"[1] SABAH\n"
"[2] SARAWAK\n"
"[3] LABUAN\n\n"
"Choose the state you prefer to go (1/2/3): ";
cin >> state;
if (state == 1)
vote++, sabah++;
else if (state == 2)
vote++, sarawak++;
else if (state == 3)
vote++, labuan++;
cout << "\nPACKAGE REMARK COST (RM) PER PAX\n"
"A Inclusive all 1600\n"
"B Exclusive food 899\n\n"
"Choose your package: ";
cin >> package;
if (package == 'A' || package == 'a')
packageA++;
else if (package == 'B' || package == 'b')
packageB++;
cout << "\nContinue with the next person (Y/N): ";
cin >> select;
while (select != 'N' && select != 'n')
{
cout << "\n[1] SABAH\n"
"[2] SARAWAK\n"
"[3] LABUAN\n\n"
"\nChoose the state you prefer to go (1/2/3): ";
cin >> state;
if (state == 1)
vote++, sabah++;
else if (state == 2)
vote++, sarawak++;
else if (state == 3)
vote++, labuan++;
cout << "\nPACKAGE REMARK COST (RM) PER PAX\n"
"A Inclusive all 1600\n"
"B Exclusive food 899\n\n"
"\nChoose your package: ";
cin >> package;
if (package == 'A' || package == 'a')
packageA++;
else if (package == 'B' || package == 'b')
packageB++;
cout << "\nContinue with the next person (Y/N): ";
cin >> select;
}
cout << "\nThe ranking summary\n"
"--------------------\n"
"Number of voters: " <<vote<< "";
{
if ((sabah >> sarawak && sarawak >> labuan) || (sabah >> sarawak && sarawak == labuan))
cout << "\n\nFirst choice : Sabah (voted by " <<sabah<< " people)\n"
"Second choice : Sarawak (voted by " <<sarawak<< " people)\n"
"Third choice: Labuan (voted by " <<labuan<< " people)\n\n";
else if (sabah >> labuan && labuan >> sarawak)
cout << "\n\nFirst choice : Sabah (voted by " <<sabah<< " people)\n"
"Second choice : Labuan (voted by " <<labuan<< " people)\n"
"Third choice: Sarawak (voted by " <<sarawak<< " people)\n\n";
else if ((sarawak >> sabah && sabah >> labuan) || (sarawak >> sabah && sabah == labuan))
cout << "\n\nFirst choice : Sarawak (voted by " <<sarawak<< " people)\n"
"Second choice : Sabah (voted by " <<sabah<< " people)\n"
"Third choice: Labuan (voted by " <<labuan<< " people)\n\n";
else if (sarawak >> labuan && labuan >> sabah)
cout << "\n\nFirst choice : Sarawak (voted by " <<sarawak<< " people)\n"
"Second choice : Labuan (voted by " <<labuan<< " people)\n"
"Third choice: Sabah (voted by " <<sabah<< " people)\n\n";
else if ((labuan >> sabah && sabah >> sarawak) || (labuan >> sabah && sabah == sarawak))
cout << "\n\nFirst choice : Labuan (voted by " <<labuan<< " people)\n"
"Second choice : Sabah (voted by " <<sabah<< " people)\n"
"Third choice: Sarawak (voted by " <<sarawak<< " people)\n\n";
else if (labuan >> sarawak && sarawak >> sabah)
cout << "\n\nFirst choice : Labuan (voted by " <<labuan<< " people)\n"
"Second choice : Sarawak (voted by " <<sarawak<< " people)\n"
"Third choice: Sabah (voted by " <<sabah<< " people)\n\n";
else if ((sabah == sarawak && sabah >> labuan) || (sabah == labuan && sabah >> sarawak) || (labuan == sarawak && labuan >> sabah))
cout << "\n\nThere is a draw for first choice. Please redo the vote.\n\n";
}
cout << "Package Preference\n"
"--------------------\n"
"Package A: Preferred by " <<packageA<< " people\n"
"Package B: Preferred by " <<packageB<< " people";
{
if (packageA >= 10 && packageA >> packageB)
cout << "\n\nA group discount of 10% is applicable for Package A. The cost per person for Package A is now RM1440.\n\n";
else if (packageA << 10 && packageA >> packageB)
cout << "\n\nThe cost per person for Package A is RM1600.\n\n";
else if (packageB >= 10 && packageB >> packageA)
cout << "\n\nA group discount of 10% is applicable for Package B. The cost per person for Package B is now RM809.10.\n\n";
else if (packageB << 10 && packageB >> packageA)
cout << "\n\nThe cost per person for Package B is RM899.\n\n";
else if (packageA == packageB)
cout << "\n\nThere is a draw in the voting. Please redo the vote.\n\n";
}
system ("pause");
return 0;
}