Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

really need help

TonyProgramsTonyPrograms Posts: 10Member
#include
#include
using namespace std;
void getTime (int);
void getDuration (int);
void getDay (char, char);
void outputCost (int,int,int,const double,const double, const double,char, char, char);
const double mid_day = 0.3;
const double night = 0.15;
const double weekend = .1;

int main ()
{
int cost=0;
int yourTime=0;
getTime (yourTime);
int yourDuration=0;
getDuration (yourDuration);
char first, second, choice('Y');
getDay (first=0, second=0);
outputCost (yourTime, yourDuration, cost, mid_day, night, weekend, first, second, choice) ;

system ("pause");
return 0;
}

void getDay (char first, char second)
{
cout<<"Please enter the day of the call in a two";
cout<<"character format, for example Monday would be Mo." <<endl;
cout<<"Please input the first two letters";
cout<<"of the day now."<<endl;
cin>> first>>second;

}

void getTime (int yourTime)
{
cout<<"Please enter the time in military format." <<endl;
cin>> yourTime;
}

void getDuration (int yourDuration)
{
cout<<"Please enter the duration of the call in minutes." <<endl;
cin>> yourDuration;
}

void outputCost (char choice,int yourTime,int yourDuration, int cost, const double mid_day, const double night, const double weekend, char first, char second)
{
if (first=='M'||first=='m'&& second=='o'||second=='O')
{
((yourTime>=700)||(yourTime<=2100));

cost=(int)(yourDuration* mid_day);
}
else
{
cost=(int)(yourDuration* night);
}


cout<<"The phone call cost $ "<<cost <<endl;
cout<<endl;
cout<<"Do you want to run the program again? Enter Y or N" <<endl;
cin>>choice;
cout<<endl;
}





Here is my code, and when i try to compile this error shows: error LNK2019: unresolved external symbol "void __cdecl outputCost(int,int,int,double,double,double,char,char,char)" (?outputCost@@YAXHHHNNNDDD@Z) referenced in function _main

Comments

  • pseudocoderpseudocoder Posts: 673Member ✭✭


    Since you've declared your const doubles as global, you don't need them in your function prototype and definition parameter lists, or in the actual call.

    The error is your prototype and definitions don't match. In the prototype, you've got

    (int,int,int,const double,const double, const double,char, char, char)

    but in the definition, you've got

    (char choice,int yourTime,int yourDuration, int cost, const double mid_day, const double night, const double weekend, char first, char second)

    move "char choice" to the end to match the caller.

    HTH
  • rdlrdl Posts: 5Member
    Now this program is producing o/p. But this program doesn't have full sense. Use pass by pointers.


    #include
    #include
    #include
    using namespace std;
    void getTime (int *);
    void getDuration (int *);
    void getDay (char *, char *);
    void outputCost (int *,int *,int *,char *,char *);
    const double mid_day = 0.3;
    const double night = 0.15;
    const double weekend = .1;

    int main ()
    {
    int cost;
    int yourTime;
    //char choice;

    getTime (&yourTime);
    cout<<"The ime is"<<yourTime<<endl;
    int yourDuration;
    getDuration (&yourDuration);
    char first, second;
    getDay (&first, &second);
    cout<<first<<second<<endl;
    outputCost (&cost,&yourTime,&yourDuration,&first,&second) ;
    cout<<"The phone call cost $ "<<cost <<endl;
    cout<<endl;

    //system ("pause");
    return 0;
    }

    void getDay (char *first, char *second)
    {
    cout<<"Please enter the day of the call in a two";
    cout<<"character format, for example Monday would be Mo." <<endl;
    cout<<"Please input the first two letters";
    cout<<"of the day now."<<endl;
    cin>> *first >> *second;

    }

    void getTime (int *yourTime)
    {
    cout<<"Please enter the time in military format." <<endl;
    cin >> *yourTime;
    }

    void getDuration (int *yourDuration)
    {
    cout<<"Please enter the duration of the call in minutes." <<endl;
    cin >> *yourDuration;
    }

    void outputCost (int *cost,int *yourTime,int *yourDuration, char *first, char *second)
    {
    //int cost=0;
    if (*first=='M'||*first=='m'&& *second=='o'||*second=='O')
    {
    ((*yourTime>=700)||(*yourTime<=2100));

    *cost=(int)(*yourDuration * mid_day);
    }
    else
    {
    *cost=(int)(*yourDuration * night);
    }

    cout<<"cost"<<*cost;

    }











  • rdlrdl Posts: 5Member
    Now this program is producing o/p. But this program doesn't have full sense. Use pass by pointers.


    #include
    #include
    #include
    using namespace std;
    void getTime (int *);
    void getDuration (int *);
    void getDay (char *, char *);
    void outputCost (int *,int *,int *,char *,char *);
    const double mid_day = 0.3;
    const double night = 0.15;
    const double weekend = .1;

    int main ()
    {
    int cost;
    int yourTime;
    //char choice;

    getTime (&yourTime);
    cout<<"The ime is"<<yourTime<<endl;
    int yourDuration;
    getDuration (&yourDuration);
    char first, second;
    getDay (&first, &second);
    cout<<first<<second<<endl;
    outputCost (&cost,&yourTime,&yourDuration,&first,&second) ;
    cout<<"The phone call cost $ "<<cost <<endl;
    cout<<endl;

    //system ("pause");
    return 0;
    }

    void getDay (char *first, char *second)
    {
    cout<<"Please enter the day of the call in a two";
    cout<<"character format, for example Monday would be Mo." <<endl;
    cout<<"Please input the first two letters";
    cout<<"of the day now."<<endl;
    cin>> *first >> *second;

    }

    void getTime (int *yourTime)
    {
    cout<<"Please enter the time in military format." <<endl;
    cin >> *yourTime;
    }

    void getDuration (int *yourDuration)
    {
    cout<<"Please enter the duration of the call in minutes." <<endl;
    cin >> *yourDuration;
    }

    void outputCost (int *cost,int *yourTime,int *yourDuration, char *first, char *second)
    {
    //int cost=0;
    if (*first=='M'||*first=='m'&& *second=='o'||*second=='O')
    {
    ((*yourTime>=700)||(*yourTime<=2100));

    *cost=(int)(*yourDuration * mid_day);
    }
    else
    {
    *cost=(int)(*yourDuration * night);
    }

    cout<<"cost"<<*cost;

    }











  • rdlrdl Posts: 5Member
    Use pass by pointers.Now its working properly.


    #include
    #include
    #include
    using namespace std;
    void getTime (int *);
    void getDuration (int *);
    void getDay (char *, char *);
    void outputCost (int *,int *,int *,char *,char *);
    const double mid_day = 0.3;
    const double night = 0.15;
    const double weekend = .1;

    int main ()
    {
    int cost;
    int yourTime;
    //char choice;

    getTime (&yourTime);
    cout<<"The ime is"<<yourTime<<endl;
    int yourDuration;
    getDuration (&yourDuration);
    char first, second;
    getDay (&first, &second);
    cout<<first<<second<<endl;
    outputCost (&cost,&yourTime,&yourDuration,&first,&second) ;
    cout<<"The phone call cost $ "<<cost <<endl;
    cout<<endl;

    //system ("pause");
    return 0;
    }

    void getDay (char *first, char *second)
    {
    cout<<"Please enter the day of the call in a two";
    cout<<"character format, for example Monday would be Mo." <<endl;
    cout<<"Please input the first two letters";
    cout<<"of the day now."<<endl;
    cin>> *first >> *second;

    }

    void getTime (int *yourTime)
    {
    cout<<"Please enter the time in military format." <<endl;
    cin >> *yourTime;
    }

    void getDuration (int *yourDuration)
    {
    cout<<"Please enter the duration of the call in minutes." <<endl;
    cin >> *yourDuration;
    }

    void outputCost (int *cost,int *yourTime,int *yourDuration, char *first, char *second)
    {
    //int cost=0;
    if (*first=='M'||*first=='m'&& *second=='o'||*second=='O')
    {
    ((*yourTime>=700)||(*yourTime<=2100));

    *cost=(int)(*yourDuration * mid_day);
    }
    else
    {
    *cost=(int)(*yourDuration * night);
    }

    cout<<"cost"<<*cost;

    }










  • TonyProgramsTonyPrograms Posts: 10Member
    ok i did that and it debugged successfully but now the math doesnt calculate correctly
  • TonyProgramsTonyPrograms Posts: 10Member
    this was very helpful but wouldnt the output cost need to be used in the output cost function, why have you moved it to the main function
Sign In or Register to comment.