long story short,For my project I have to calculate the cost of a mobile device service. I ask a user what package they want package a, b, or c. they each have a base price. right now im trying to calculate the cost of package a which has a base price of $9.95. I also ask the user how many many message units they want. if they choose more than 5 message units its $1.00 per message unit after 5 units. I dont know if my math is not right? when i run it it gives the wrong output for the price.
#include <iostream>
using namespace std;
int main()
{
char a = 9.95;
char b = 19.95;
char c = 39.95;
int x=1, messageunits, Atotalcost;
do
{
cout << "Which package do you choose(enter a, b, c,)" << endl;
cin >> a || b || c;
x++;
}
while(x < 2);
do
{
cout << "how many message units(enter 1 - 672)" << endl;
cin >> messageunits;
x++;
}
while(x < 2);
if(messageunits > 5){
Atotalcost = a + (messageunits * 1.00);
cout << "Your total cost is " << Atotalcost << endl;
}
else
cout << "Your total cost is 9.95" << endl;
}
Do you pay attention to the warnings generated by your compiler?
Do you believe a floating point value can be held in a variable of type char?
What do you believe is happening in cin >> a || b || c;?