So So close. I think.

PLEASE IGNORE I COPIED AND PASTED WRONG....
Hi everyone. First off I am sorry that this code is no where near beautiful. I am a new cs student who is just trying to survive intro comp sci and comp sci 2. My question is how can i get the account number the user has entered appear first in the output?

For example I would like the program to output:
The Account Number.
The Service Type. (Premium or Regular)
The total number of minutes used.
and the amount of money due.

So far it does everything with the exception of outputting the Account Number. If someone could show me what I am doing wrong I would appreciate it.

Thanks. :)

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
127
  #include <iostream>
#include <iomanip>
#include <string>
using namespace std;

void regular() //function to calculate the regular service charge.
{
  int min;
  float startReg = 10.00;
  cout<<"Enter Minutes Used." << endl;
  cin>> min;
  if(min < 50)
    {
      cout<<left;
      cout<< setw(30)<< "Service: " << "Regular" << endl;
      cout<< setw(30)<< "Number of minutes used: " << min << endl;
      cout<< setprecision(2) << fixed;
      cout<< setw(30)<< "Amount Due: " << startReg << endl;
    }
  else
    {
      cout<<left;
      cout<< setw(30)<< "Service: " << "Regular" << endl;
      cout<< setw(30)<< "Number of minutes used: " << min << endl;
      cout<< setprecision(2) << fixed;
      startReg = 10.00 + (min * 0.20);
      cout<< setw(30)<<"Amount Due: " << "$" << startReg << endl;
    }
}
void premium() //function to calculate the premium service charge.
{
  int minDay;
  int minNight;
  float startRegPre = 25.00;
  float endRegPrice;
  float endRegPriceN;

  cout<<"Enter minutes used between 6:00 AM and 6:00 PM" << endl;
  cin>> minDay;

  cout<<"Enter minutes used between 6:00 PM and 6:00 AM" << endl;
  cin>>minNight;
  if(minDay < 75) // premium day minutes.
    {
      cout<< left;
      cout<< setw(30) << "Service: " << "Premium" << endl;
      cout<< setw(30) << "Number of minutes used: " << minNight + minDay << endl;
      cout<< setprecision(2) << fixed;
return;
    }
  else if (minNight > 100);
  {
    cout<< left;
    cout<< setw(30)<< "Number of minutes used: " << minNight + minDay << endl;
    cout<< setprecision(2) << fixed;
    endRegPriceN = (minNight - 100) * 0.05;
    cout<< setw(30) << "Amount Due: " << "$" <<(endRegPriceN + startRegPre) << endl;
    return;
  }
}

int main() //main function.  Takes the service code and account number.
{
  char service;
  string account;
  cout<<"Welcome to the phone bill calculator!" << endl;
  cout<<"-------------------------------------" << endl;
  cout<<"Enter Account Number" << endl;
  cin>> account;
  cout<<"Enter service code" << endl;
  cin>> service;
  switch (service) // switch statement using the service code as a expression.
    {
    case 'r':
    case 'R':
      regular(); // calling the regular service function defined in the start of the program.
      break;

    case 'p':
    case 'P':
      premium(); //calling the premium service function defined in the start of the program.
      break;

    default: // default statement
      cout<<"Enter valid code" << endl;
    }
}
return;
    }
  else if (minNight > 100);
  {
    cout<< left;
    cout<< setw(30)<< "Number of minutes used: " << minNight + minDay << endl;
    cout<< setprecision(2) << fixed;
    endRegPriceN = (minNight - 100) * 0.05;
    cout<< setw(30) << "Amount Due: " << "$" <<(endRegPriceN + startRegPre) << endl;
    return;
  }
}

int main() //main function.  Takes the service code and account number.
{
  char service;
  string account;
  cout<<"Welcome to the phone bill calculator!" << endl;
  cout<<"-------------------------------------" << endl;
  cout<<"Enter Account Number" << endl;
  cin>> account;
  cout<<"Enter service code" << endl;
  cin>> service;
  switch (service) // switch statement using the service code as a expression.
    {
    case 'r':
    case 'R':
      regular(); // calling the regular service function defined in the start of the program.
      break;

    case 'p':
    case 'P':
      premium(); //calling the premium service function defined in the start of the program.
      break;

    default: // default statement
      cout<<"Enter valid code" << endl;
    }
}
Last edited on
closed account (48T7M4Gy)
For a start, why have you got 2 no. int main()'s? You can only have 1. :)
closed account (48T7M4Gy)
Where have you put cout << account; ?? That's probably why it isn't printing out.
shit i copied and pasted the same thing twice. I am sorry please ignore everything. I'll post a new topic tomorrow.
closed account (48T7M4Gy)
No problem. :)
Topic archived. No new replies allowed.