We are just learning user defined functions. Instructor has us taking a prev assignment and pulling the calculations into functions. I thought I understood how to do the function, but guess not I''m getting the "error term does not evaluate to a function taking 0 arguments." I have been working on this for 3 days. I've looked to make that the function isn't named the same as a variable. Can someone be kind enough to nudge me in the correct direction? Thank you for your time.
#include <iostream>
#include <iomanip>
using namespace std;
//Named constants – Regular Service
const double REG_BASIC_SERV_COST = 10;
const double REG_OVER_MIN_CHRG = .20;
const double REG_MINUTES_FREE = 50;
//Named constants – Premium Serivce
const double PREM_BASIC_SERV_COST = 25.00;
const double PREM_DAY_FREE_MIN = 75;
const double PREM_NIGHT_FREE_MIN = 100;
const double PREM_DAY_OVER_CHRG = .10;
const double PREM_NIGHT_OVER_CHRG = .05;
const double PREM_OVER_MIN = .10;
double RegularBill;
double PremiumBill;
int main()
{
//Variable declaration
int AccountNumber;
char ServiceType;
int RegServiceMinutes;
int PremDayMinutes;
int PremNightMinutes;
double AmountDue;
cout << fixed << showpoint;
cout << setprecision(2);
cout << "This program calculates and prints a cellular phone bill" << endl;
cout << endl;
cout << "Enter account number: " ;
cin >> AccountNumber;
cout << endl;
cout << "Enter Service type: "
<< "R or r (Regular Service), "
<< "P or p (Premium Service): ";
cin >> ServiceType;
cout << endl;
switch (ServiceType)
{
case 'r':
case 'R':
AmountDue = RegularBill();
cout << "Account Number: " << AccountNumber << endl;
cout << "Type of Service: " << ServiceType << endl;
cout << "Amount Due: $" << bAmount << endl;
break;
case 'p':
case 'P':
AmountDue = PremiumBill();
cout << "Account Number: " << AccountNumber << endl;
cout << "Type of Service: " << ServiceType << endl;
cout << "Amount Due: $" << bAmount << endl;
break;
default:
cout << "Invalid customer type." << endl;
cout << "Program terminates" << endl;
} //end switch
system ("pause");
return 0;
}
double RegularBill()
double bAmount;
{
cout << "Enter number of minutes used for Regular Service: ";
cin >> RegServiceMinutes;
cout << endl;
if (RegServiceMinutes <= REG_MINUTES_FREE)
{
bAmount = REG_BASIC_SERV_COST << endl;
else
bAmount = REG_BASIC_SERV_COST +(RegServiceMinutes - REG_MINUTES_FREE)
* REG_OVER_MIN_CHRG;
}
return bAmount;
}
double PremiumBill()
{
double bAmount;
//double AmountDue;
cout << "Enter the number minutes used during the day: ";
cin >> PremDayMinutes;
cout << endl;
cout << "Enter the number of minutes used during the evening: ";
cin >> PremNightMinutes;
cout << endl;
bAmount = PREM_BASIC_SERV_COST;
if (PremDayMinutes > PREM_DAY_FREE_MIN)
{
bAmount = bAmount +(PremDayMinutes - PREM_DAY_FREE_MIN)
* PREM_DAY_OVER_CHRG;
if (PremNightMinutes > PREM_NIGHT_FREE_MIN)
bAmount = bAmount + (PremNightMinutes - PREM_NIGHT_FREE_MIN)
* PREM_NIGHT_OVER_CHRG;
else
bAmount = PREM_BASIC_SERV_COST;
return bAmount;
}