Halloween project

Working on a assignment, needs to be done soon so if you can help please do as soon as possible. It runs and everything is good how it should be but, im having issues with getting it to show the total amount it should come out to $553.35 if you enter 40 for kruger and 53 for stein. but i cant get it to show the cents. it just shows the dollars.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <string>
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
	int kruger, stein, ghoul, total;
	cout << "A reward is being handed out of $5.95 per each ghoul sighting... so... :)"<< endl;
	cout << "How many times has Freddy Kruger been sighted?";
	cin>> kruger;
	cout << "How many times has Frank N. Stein been sighted?";
	cin>> stein;
	total = kruger + stein;
	cout << "That is a total amount of sightings are " << total;
	cout << " YIKES!!!!!" << endl;
	ghoul = 5.95*total;
	cout << "The total reward amount of ghoul sightings is $" << ghoul << endl;
	system("pause");
	return 0;
}
That's because you're using total as an int, switch it to double and you should be just fine!
Thank you so much ian!! :D thank you thank you thank you
No problem!

Also you might want to set the precision to,

std::cout.precision(3);
that way if you have more than 2 decimal places, it only shows the first 2!
Last edited on
where would i add that exactly? just anywhere? im familiar with that just never knew how to use it. my teachers extremely rude when people ask him questions so like i never bothered
Anywhere before it is used or called, I usually just stick it in after my integers and before any of the main code.
okay thank you so much for all your help Ian i appreciate it :D
Topic archived. No new replies allowed.