Boy scout chocolate sales. The output should be arranged depending on the amount of chocolates sold. Example; the lowest amount should always be at third place. Getting a lot of errors.
Need the output to be a table. Should look something like this:
Rank Sales Commission
Third $43.75 $2.18
Second $75.00 $5.25
First $156.25 $15.63
List of errors are as follows:
Error 1 error C2059: syntax error : '<' f:\cois 270\projects\examen final\examen final\examenf.cpp 37 Examen Final
Error 2 error C2143: syntax error : missing ';' before '{' f:\cois 270\projects\examen final\examen final\examenf.cpp 38 Examen Final
Error 3 error C2143: syntax error : missing ';' before '==' f:\cois 270\projects\examen final\examen final\examenf.cpp 39 Examen Final
Error 4 error C2059: syntax error : '<' f:\cois 270\projects\examen final\examen final\examenf.cpp 41 Examen Final
Error 5 error C2143: syntax error : missing ';' before '{' f:\cois 270\projects\examen final\examen final\examenf.cpp 42 Examen Final
Error 6 error C2143: syntax error : missing ';' before '==' f:\cois 270\projects\examen final\examen final\examenf.cpp 43 Examen Final
Error 7 error C2059: syntax error : '<' f:\cois 270\projects\examen final\examen final\examenf.cpp 45 Examen Final
Error 8 error C2143: syntax error : missing ';' before '{' f:\cois 270\projects\examen final\examen final\examenf.cpp 46 Examen Final
Error 9 error C2143: syntax error : missing ';' before '==' f:\cois 270\projects\examen final\examen final\examenf.cpp 47 Examen Final
Error 10 error C2450: switch expression of type 'std::string' is illegal f:\cois 270\projects\examen final\examen final\examenf.cpp 55 Examen Final
Error 11 error C2051: case expression not constant f:\cois 270\projects\examen final\examen final\examenf.cpp 57 Examen Final
Error 12 error C2051: case expression not constant f:\cois 270\projects\examen final\examen final\examenf.cpp 60 Examen Final
Error 13 error C2051: case expression not constant f:\cois 270\projects\examen final\examen final\examenf.cpp 63 Examen Final
Warning 14 warning C4060: switch statement contains no 'case' or 'default' labels f:\cois 270\projects\examen final\examen final\examenf.cpp 66 Examen Final
Here's the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#include <iostream>
#include <iomanip>
#include <string>
using std::cout;
using std::cin;
using std::endl;
using std::string;
using std::setprecision;
using std::ios;
using std::setiosflags;
int main()
{
int chocolates = 0;
double sales = 0;
double commission = 0;
string rank = "";
cout << "Enter the first amount of chocolates: ";
cin >> chocolates;
cout << "Enter the second amount of chocolates: ";
cin >> chocolates;
cout << "Enter the third amount of chocolates: ";
cin >> chocolates;
cout << endl;
sales = chocolates * 1.25;
if (sales =< 50)
{
string rank == "Third";
}
if (sales =< 100)
{
string rank == "Second";
}
if (sales =< 150)
{
string rank == "First";
}
cout << setiosflags(ios::fixed) << setprecision(2);
cout << " Rank" << " Sales" << " Commission";
switch (rank)
{
case "Third": commission = sales * .05;
cout << " " << sales << " " << commission << endl;
break;
case "Second": commission = sales * .07;
cout << " " << sales << " " << commission << endl;
break;
case "First": commission = sales * .010;
cout << " " << sales << " " << commission << endl;
break;
}
return 0;
}
|
Any advice or criticism is welcome. I'm fairly stumped on this one.