help with the function

function
Last edited on
[Linker error] undefined reference to `getPlan_Minutes(int, int)'
[Linker error] undefined reference to `getPlan_Text(int&, int&)'

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
#include <iostream>
#include <iomanip>
#include <cctype>

using namespace std;

void getPlan_Minutes(int A, int B);
void getPlan_Text(int& A, int& B);
void outputBill(char PLAN, int MINUTES,double A,double B, int Tellphone);

float const plan_A = 10;       //code h - monthly base charge for home customer plan

float const plan_B = 20;   
int main()
{
     int Tellphone;
     char plan;
     int minutes;
     int text;
     int A,B;
     char getPlan;
     int getMinutes;
	 float getText;
     
     double billA;
     
     double billB;
       cout << "This program will calculate and show you your cellular phone bill for one month." << endl << endl;

    
          cout << "Please input your phone number: ";
          cin >> Tellphone;
          cout << endl;
       
     getPlan_Minutes(A,B);
     getPlan_Text(A,B);
     

     system ("PAUSE");
     return 0;
}
void getPlan_Minutes(char& PLAN, int& MINUTES,double& A,double& B)
{
cout << "AVAILABLE PLANS:" << endl;

cout << "A" << endl;

cout << "B"<< endl << endl;
cout << "Please choose the letter of your plan from above: ";
cin >> PLAN;
PLAN = toupper (PLAN);
cout << endl << "Your chosen plan is: " << endl;

// Read letter of plan and output description

switch (PLAN) {               //start switch plan
     

     

     case 'A':
          cout << "A - Home customer plan - $10/first 60 minutes used, plus 25 cents each additional minute"
                  << endl << endl;
          cout << "Please input your minutes used: ";
          cin >>  MINUTES;
          
          if (PLAN == 'A')
          if ( MINUTES > 60)
               A = plan_A + (.25 *  MINUTES);
          else
               A = plan_A;
          cout << endl;
          break;

     case 'B':
          cout << "B - Business customer plan - $150 up to 2,000 minutes, $210 up to 3,000 minutes, $240/over 3,000 "
                  "minutes" << endl << endl;
          cout << "Please input your minutes used: ";
          cin >> MINUTES;
          
          cout << endl;
          break;

     default:
          cout << "Please enter a valid plan letter from above: ";
          cin >> PLAN;
          break;

     }         //end switch plan
}  
void getPlan_Text(char PLAN,int Text,double& A, double& B)
  {
  if (PLAN == 'A')
          if ( Text > 100)
               A =Text-100*.25;
          else
               A = plan_A;
    
     else if (PLAN == 'B')
          if ( Text >= 75)
               B = Text-75*.20;
          else 
          B= plan_B;
     }
Your Function definitions are different to the declaration.

1
2
void getPlan_Minutes(int A, int B);
void getPlan_Text(int& A, int& B);


void getPlan_Minutes(char& PLAN, int& MINUTES,double& A,double& B)

void getPlan_Text(char PLAN,int Text,double& A, double& B)


These things must match.
how should it be sir
Make the arguments in the declarations, the same type as the arguments in the function definition.
good this time i got it sir but no out put for minute and text used
can you help me why
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
128
129
130
131
132
133
134
#include <iostream>
#include <iomanip>
#include <cctype>

using namespace std;

void getPlan_Minutes(char& PLAN, int& MINUTES,double& A,double& B);
 
void getPlan_Text(char PLAN,int Text,double& A, double& B);
void outputBill(char PLAN, int MINUTES,double A,double B, int Tellphone);

float const plan_A = 10;       //code h - monthly base charge for home customer plan

float const plan_B = 20;   
int main()
{
     int Tellphone;
     char plan;
     int minutes;
     int text;
    
     char getPlan;
     int getMinutes;
	 float getText;
     
     double billA;
     
     double billB;
       cout << "This program will calculate and show you your cellular phone bill for one month." << endl << endl;

    
          cout << "Please input your phone number: ";
          cin >> Tellphone;
          cout << endl;
       
getPlan_Minutes(plan,minutes,billA,billB);
 
getPlan_Text(plan,text,billA,billB);
     

     system ("PAUSE");
     return 0;
}
void getPlan_Minutes(char& PLAN, int& MINUTES,double& A,double& B)
{
cout << "AVAILABLE PLANS:" << endl;

cout << "A" << endl;

cout << "B"<< endl << endl;
cout << "Please choose the letter of your plan from above: ";
cin >> PLAN;
PLAN = toupper (PLAN);
cout << endl << "Your chosen plan is: " << endl;

// Read letter of plan and output description

switch (PLAN) {               //start switch plan
     

     

     case 'A':
          cout << "A - Home customer plan - $10/first 60 minutes used, plus 25 cents each additional minute"
                  << endl << endl;
          cout << "Please input your minutes used: ";
          cin >>  MINUTES;
          
         // if (PLAN == 'A')
          if ( MINUTES > 60)
               A = MINUTES-60*.25;
          else
               A = plan_A;
          cout << endl;
          break;

     case 'B':
          cout << "B - All minutes over 30 are charged 15 cents a minute "<< endl << endl;
          cout << "Please input your minutes used: ";
          cin >> MINUTES;
         // if(PLAN=='B')
           if(MINUTES > 30)
           B=MINUTES-30*.15;
           else
              B=plan_B;
          cout << endl;
          break;

     default:
          cout << "Please enter a valid plan letter from above: ";
          cin >> PLAN;
          break;

     }         //end switch plan
}  
void getPlan_Text(char PLAN,int Text,double& A, double& B)
  {
  if (PLAN == 'A')
          if ( Text > 100)
               A =Text-100*.25;
          else
               A = plan_A;
    
     else if (PLAN == 'B')
          if ( Text >= 75)
               B = Text-75*.20;
          else 
          B= plan_B;
     }
void outputBill(char PLAN, int MINUTES,double A,double B, int Tellphone)
{
     double total;
     cout << "YOUR MONTHLY BILL" << endl << endl;
     cout << setw(20);
     cout << "Your account number: " << Tellphone << endl;
     cout << "Your plan: " << PLAN << endl;
     //if (PLAN != 'F')
     cout << "Your minutes: " << fixed << showpoint << setprecision(2) << setw(20) <<  MINUTES << endl;
     cout << "Total due: " ;

     switch (PLAN) {               //start switch plan

          

          case 'A':
               total = A;
               break;

          case 'B':
               total = B;
               break;
     }
	 cout<<total<<endl;
}
That's because you're not calling your outputBill function.
Last edited on

why my logic dosent work i dont get the write result


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
switch (PLAN) {               //start switch plan
     

     

     case 'A':
          cout << "A - Home customer plan - $10/first 60 minutes used, plus 25 cents each additional minute"
                  << endl << endl;
          cout << "Please input your minutes used: ";
          cin >>  MINUTES;
          
         if (PLAN == 'A')
          if ( MINUTES > 60)
               A = plan_A+(MINUTES*.25);
          else
               A = plan_A;
          cout << endl;
          break;

     case 'B':
          cout << "B - All minutes over 30 are charged 15 cents a minute "<< endl << endl;
          cout << "Please input your minutes used: ";
          cin >> MINUTES;
         if(PLAN=='B')
           if(MINUTES > 30)
           B=plan_B+(30*0.15);
           else
              B=plan_B;
          cout << endl;
          break;

     default:
          cout << "Please enter a valid plan letter from above: ";
          cin >> PLAN;
          break;
What result do you get?

What result do you expect to get?

We can't read your mind - we need you to tell us what's happening!
Topic archived. No new replies allowed.