The code I wrote is supposed to show the billing amount. It compiles fine and gives no runtime errors but fails to provide any output and gives the "Improper selection. Please Choose R or P" error regardless of what letter is typed.

//switch statements
//The program compiles fine and does not give any error messages when run but
//it seems that the switch statement doesn't run the functions

#include <iostream>

using namespace std;


double getAcctNumber (double acctNumber);

char getServiceCode (char serviceCode);

int regularPlan ();

int premiumPlan ();


int main ()
{
double acctNumber;

char serviceCode;

double totalCost;

int totalMinutes;


getAcctNumber (acctNumber);

getServiceCode (serviceCode);


switch (serviceCode)
    {
    case 'R':
    case 'r':
      regularPlan ();
      break;

    case 'P':
    case 'p':
      premiumPlan ();
      break;

    default:
      cout <<"Error: Improper selection. Please Choose R or P";

      return 0;
    }

cout <<"Your account number is"<< acctNumber;

cout <<"Your total bill for "<< totalMinutes <<" minutes is $"<< totalCost;


 return 0;
}


double getAcctNumber (double acctNumber) //Asks for acct number
{
cout << "Please enter your account number: ";
cin >> acctNumber;
return acctNumber;
}


char getServiceCode (char serviceCode) //Asks for service code
{
cout << "Please enter your service code: ";
cin >> serviceCode;
return serviceCode;
}


int regularPlan () //Calculates plan for regular service
{
 int totalMinutes;
 double totalCost;

 cout <<"Type the number of totalMinutes:";
 cin>> totalMinutes;

 if ( totalMinutes > 50)
    {
    totalCost = (totalMinutes - 50) * .20 + 10.00;
 }

 else
    {
    totalCost = 10.00;
    }
 return totalMinutes;
 return totalCost;
}


int premiumPlan () //Calculates plan for premium service
{
int dayMinutes;
int nightMinutes;
int totalMinutes;
double totalCost;
double costDay;
double costNight;

 cout <<"Please enter the number of day minutes used:";
 cin >> dayMinutes;

 cout <<"Please enter the number of night minutes used:";
 cin >> nightMinutes;

 if (dayMinutes > 75)
    {
    costDay = (dayMinutes - 75) * .10;
    }
 else
    {
    costDay = 0;
    }

 if (nightMinutes > 100)
    {
    costNight = (nightMinutes - 100) * .05;
    }
 else
    {
    costNight=0;
    }
 totalCost = 25.00 + costDay + costNight;
 totalMinutes = dayMinutes + nightMinutes;
 return totalMinutes;
 return totalCost;
}

You have a function declaration of char getServiceCode (char serviceCode); that you try to pass your char serviceCode variable to.

You need to either pass the variable instance or a pointer to the variable, otherwise nothing will be assigned from the function to the serviceCode address space.

Just change your function to: void getServiceCode(char &serviceCode)
That way you'll be working directly with the instance of variable serviceCode, hence no reason to return a char.

The same also applies to your getAcctNumber function.

This gives the following:

Line 74: error: return-statement with a value, in function returning 'void'

That's because you haven't changed the function and are still returning a char. return serviceCode;
Just change it to return;

void getServiceCode (char &serviceCode)
{
    cout << "Please enter your service code: ";
    cin >> serviceCode;
    return;  // this line can be omitted, though I prefer to include it.
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.