im in a c++ class and i cant figure out why one of my assignments doesnt work. more specifically the switch doesnt work. heres my code
#include <iostream>
using namespace std;
const double pencil = .3, pen = 1.25, eraser = .72, d1 = .1, d2 = .07, d3 = .05;
void main()
{
int selection, purchasing;
double cost;
cout << "What of the following are you purchasing:" << endl;
cout << "Choose from the following:" << endl;
cout << "A. Pens" << endl;
cout << "B. Pencils" << endl;
cout << "C. Erasers" << endl;
cout << "Enter your selection: ";
cin >> selection;
cout << endl << endl;
switch (selection)
{
case 'A':
cout << "How many are you purchasing: ";
cin >> purchasing;
if (purchasing >= 150)
{
cost = (pen * purchasing) * d1;
cout << "The cost is $" << cost;
}
else if (purchasing < 150 && purchasing >= 100)
{
cost = (pen * purchasing) * d2;
cout << "The cost is $" << cost;
}
else
{
cost = (pen * purchasing) * d3;
cout << "The cost is $" << cost;
}
case 'B':
cout << "How many are you purchasing: ";
cin >> purchasing;
if (purchasing >= 150)
{
cost = (pencil * purchasing) * d1;
cout << "The cost is $" << cost;
}
else if (purchasing < 150 && purchasing >= 100)
{
cost = (pencil * purchasing) * d2;
cout << "The cost is $" << cost;
}
else
{
cost = (pencil * purchasing) * d3;
cout << "The cost is $" << cost;
}
case 'C':
cout << "How many are you purchasing: ";
cin >> purchasing;
if (purchasing >= 150)
{
cost = (eraser * purchasing) * d1;
cout << "The cost is $" << cost;
}
else if (purchasing < 150 && purchasing >= 100)
{
cost = (eraser * purchasing) * d2;
cout << "The cost is $" << cost;
}
else
{
cost = (eraser * purchasing) * d3;
cout << "The cost is $" << cost;
}
default:
cout << "Invalid selection!!";
}
}
In addition to what matsom said about tags, if you recieve compiler errors, please post those as well.