problem with my program's math

The math in my program is almost right. The problem is it doesn't find the cents when my if statement subtracts from a variable in the judgement function. Thanks for the help!
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

 19 #include <iostream>
 20 using namespace std;
 21
 22 float getsam(float &sam)
 23 {
 24
 25    cout << "What is Sam's balance? ";
 26
 27    cin >> sam;
 28    float *psam;
 29    psam = &sam;
 30    cerr << sam;
 31    return sam;
 32
 33 }
 34
 35 float getsue(float &sue)
 36 {
 37    cout << "What is Sue's balance? ";
 38
 39    float *psue;
 40    psue = &sue;
 41    cin >> sue;
 42    cerr << sue;
 43    return sue;
 44
 45 }
 46
 47 float cost(float &total)
 48 {
 49    cout << "Cost of the date:\n";
 50    cout << "\tDinner:    ";
 51    float dinner;
 52    cin  >> dinner;
 53    cout << "\tMovie:     ";
 54    float movie;
 55    cin  >> movie;
 56    cout << "\tIce cream: ";
 57    float ice;
 58    cin  >> ice;
 59     total = (dinner + movie + ice);
float judgement(float &sue, float &sam, float &total)
 64 {
 65    float end1;
 66    float end2;
 67    if ((sue) > (sam))
 68    {
 69     int  sueend = ((sue) - (total));
 70        cout << "Sam's balance: " << sam << endl;
 71        cout << "Sue's balance: " << sueend << endl;
 72    }
 73    if ((sam) > (sue))
 74        {
 75           int samend = ((sam) - ( total));
 76           cout << "Sam's balance: " << samend << endl;
 77           cout << "Sue's balance: " << sue << endl;
 78        }
 79
 80
 81 }
 82
 83 /**********************************************************************
 84  * Add text here to describe what the function "main" does. Also don't forget
 85  * to fill this out with meaningful text or YOU WILL LOSE POINTS.
 86  ***********************************************************************/
 87 int main()
 88 {
 89    cout.setf(ios::fixed);
 90    cout.setf(ios::showpoint);
 91    cout.precision(2);
 92    float sue;
 93    float sam;
 94    float total;
 95    float end1;
 96    float end2;
 97    getsam(sam);
 98    getsue(sue);
 99    cost(total);
100    judgement(sue, sam, total);
101
102    return 0;
103 }
Do you mean here? You've declared sueend and samend to be integers - shouldn't those also be floats?

int sueend = ((sue) - (total));
oh my gosh haha. Thanks apparently I am tired and missed that.
Topic archived. No new replies allowed.