IF/statement NOT printing

Ok so this is the OLD cell phone bill with regular and premium

i completed the Regular and had some trouble with the premium ( i honestly think i did it the hard way ) BUT i know it works ( in my head it works )

compiling this i CAN get the regular and premium starts too BUT it cuts off right after i ask for the minutes with no error

anything i am missing? would be appreciated

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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
  #include <iostream>
#include <string>
#include <fstream>
#include <iomanip>


using namespace std;

int main()
{
    double AccNum;
    char S;


    double Minutes, DayMins, NightMin, TotalPremMin;
    double Bill, OverMin, OverPrice;
    double PremOverDay, PremOverNight;

    const  double Reg = 10.00, Prem = 25.00;
    const  double OvrChrReg = .20;
    const  double OvrChrPrem1 = .10, OvrChrPrem2 = .05;
    const  double RegFreeMin = 50;
    const  double PremFreeDayMin = 75, PremFreeNightMin = 100;


    cout << "Enter an account number:" << endl;
    cin >> AccNum;

    cout << "Enter R or r for regular service.  Enter P or p for premium service." << endl;
    cin >> S;

    //Regular
    if(S == 'R' || S == 'r')
    {
        cout << "Enter the number of minutes used." << endl;
        cin >> Minutes;
        OverMin = Minutes - RegFreeMin;
        //OverCharge
        if(Minutes > 50)
        {
            OverMin = Minutes - RegFreeMin;
            OverPrice = OverMin*OvrChrReg;
            Bill = Reg + OverPrice;
            cout << "Account number " << AccNum << " with regular service.  Total minutes: " << Minutes << " Total Bill $" << fixed << setprecision(2) << Bill << endl;
        }
        //No OVERCHARGE
        else if (Minutes <= 50)
        {
            Bill = Reg;
            cout << "Account number " << AccNum << " with regular service.  Total minutes: " << Minutes << " Total Bill $" << fixed << setprecision(2) << Bill << endl;
        }

    }
    // Premium
    if(S == 'P' || S == 'p')
    {
        cout << "Enter minutes of calls made between 6:00 a.m. to 6:00 p.m." << endl;
        cin >> DayMins;

        cout << "Enter minutes of calls made between 6:00 p.m. to 6:00 a.m." << endl;
        cin >> NightMin;

        TotalPremMin = DayMins + NightMin;

        // NO OVERCHARGE
        if(DayMins < PremFreeDayMin && NightMin < PremFreeNightMin)
        {
            Bill = Prem;
            cout << "Account number " << AccNum << " with premium service.  Total minutes:" << TotalPremMin << "Total Bill $" << fixed << setprecision(2) << Bill << endl;

        }
        // Day Time Over Charge
        else if (DayMins > PremFreeDayMin && NightMin < PremFreeNightMin)
        {
            PremOverDay = DayMins - PremFreeDayMin;

            OverPrice = PremOverDay * OvrChrPrem1;

            Bill = Prem + OverPrice;

            cout << "Account number " << AccNum << " with premium service.  Total minutes:" << TotalPremMin << "Total Bill $" << fixed << setprecision(2) << Bill << endl;

        }

        // Night Time Over Charge
        else if (DayMins < PremFreeDayMin && NightMin > PremFreeNightMin)
        {
            PremOverNight = NightMin - PremFreeNightMin;

            OverPrice = PremOverNight * OvrChrPrem2;

            Bill = Prem + OverPrice;

            cout << "Account number " << AccNum << " with premium service.  Total minutes:" << TotalPremMin << "Total Bill $" << fixed << setprecision(2) << Bill << endl;

        }

        // DOUBLE OVER CHARGE
         else if (DayMins > PremFreeDayMin && NightMin > PremFreeNightMin)
            {
            PremOverDay = DayMins-PremFreeDayMin;

            PremOverNight = NightMin- PremFreeNightMin;

            OverPrice = (PremOverDay * OvrChrPrem1) + (PremOverNight * OvrChrPrem2);

            Bill = Prem + OverPrice;

            cout << "Account number " << AccNum << " with premium service.  Total minutes:" << TotalPremMin << "Total Bill $" << fixed << setprecision(2) << Bill << endl;

            }




    }

    else
    {
        cout << "Invalid Entry " << endl;
    }



    return 0;
}
Last edited on
There is no error. The program simply ends (and hence the window is closed) before you can see the result.
What happens in the "Premium" case if
DayMins == PremFreeDayMin
or if
NightMin == PremFreeNightMin
Hello xavega4217,

In addition to what coder777 has said read through this:

http://www.cplusplus.com/forum/beginner/1988/

Andy
Topic archived. No new replies allowed.