### Help with Exact values

Hey guys! I am working on a program for my computer science class, and we were told to make a calculator that calculates the total of a purchase at a movie theater. So..my problem is...for some reason it calculates the total but it does not show the decimal point.

so in my program if I were to just put 1 in the amount of adult tickets purchased and 0 for childticket, then it should show a total of 10.50, but it only shows 10 and not the 50 cents!
Any help for a freshman computer science major would be great!

Thanks for the help Moschops! Didn't notice to double my integers
Last edited on
`int adultticket , adultprice, childticket, childprice;`

I see you have chosen to use int variables. These are integers. Whole numbers. There is no decimal point.

Edit: For the forum archaeologists, here's the original post:

Hey guys! I am working on a program for my computer science class, and we were told to make a calculator that calculates the total of a purchase at a movie theater. So..my problem is...for some reason it calculates the total but it does not show the decimal point.

For example:

 ``12345678910111213141516171819202122232425262728`` `````` double totalprice; int adultticket , adultprice, childticket, childprice; int main() { /*int adult ticket, adultprice, child ticket, childprice,Total Price,end1;*/ //Get the amount of adult tickets. cout << "Please enter the number of adult tickets that are being purchased: "; cin >> adultticket; adultprice = 10.50; //Get the amount of child tickets. cout << "Please enter the number of child tickets that are being purchased: "; cin >> childticket; childprice = 5.00; //Calculate the total amount. totalprice = (adultticket * adultprice) + (childticket * childprice); //Display the force. cout << "The total purchase price is " << totalprice << " dollars " << endl; system("PAUSE"); return 0; }``````

so in my program if I were to just put 1 in the amount of adult tickets purchased and 0 for childticket, then it should show a total of 10.50, but it only shows 10 and not the 50 cents!
Any help for a freshman computer science major would be great!
Last edited on
Topic archived. No new replies allowed.