weekly help flyn with his C++ thread

Discussion in 'OT Technology' started by flynfrog, Mar 14, 2003.

  1. flynfrog

    flynfrog Cool isnt Cheap

    Joined:
    Jul 16, 2001
    Messages:
    6,620
    Likes Received:
    6
    Location:
    Utah
    Code:
    #include <iostream.h>
    #include <math.h>
    #include <stdlib.h>
    //function prototypes
    void total (int, float, float, float);
    void total (float, float);
    
    int main (void)
    {
     // declare variables
     int choice, days;
     float rate, meds, tests;
    // In or out paitent
    
    cout << "If the pateing was an in paiten please press 1 \n";
    cout << "If the patien was an out paitent please press 2 \n";
    cin >> choice;
    //enter values
    switch (choice)
     {
      case 1:
       cout << "Please enter number of days patient was in hospital\n";
       cin >> days;
       cout << "Please enter the daily rate\n";
       cin >> rate;
       cout << "Please enter any medication charges recived\n";
       cin >> meds;
       cout << "Please enter charges for any labs or tests\n";
       cin >> tests;
       void total (int, float, float, float);;
      break;
    
    
      case 2:
       cout << "Please enter any charges for labs or tests\n";
       cin >> tests;
       cout << "Please enter any charges for medication\n";
       cin >> meds;
       void total (float, float);
      break;
    
     }
     system("pause");
     return 0;
    }
    
    // in patient total
    void total (int days, float rate, float meds, float tests)
    {
      float daysubtotal, total;
    daysubtotal = days * rate;
    total = daysubtotal + meds + tests;
    cout << "days " << days << endl;
    cout << "at a rate of " << rate << endl;
    cout << "sub total " << daysubtotal << endl;
    cout << "medication " << meds << meds;
    cout << "labs and tests " << tests <<endl;
    cout << "your total comes to" << total << endl;
    }
    
    // out patient
    void total (float tests, float meds)
    {
    float total;
    total = tests + meds;
    cout << "Medication " << meds << endl;
    cout << "Labs and Test " << tests << endl;
    cout << "your total comes too " << total << endl;
    }
    
    i think i called my functions wrong i also need to change input to two overloaded functions and i have no idea how to do this
     
  2. crotchfruit

    crotchfruit Guest

    so.. what's your question?

    also, generally speaking, it's not such a great idea to create variables w/ the same name as the function they're in. i.e. your 'float total' declarations inside of the 'total' functions.
     
  3. flynfrog

    flynfrog Cool isnt Cheap

    Joined:
    Jul 16, 2001
    Messages:
    6,620
    Likes Received:
    6
    Location:
    Utah
    Code:
    #include <iostream.h>
    #include <math.h>
    #include <stdlib.h>
    //function prototypes
    void total (int, float, float, float);
    void total (float, float);
    
    int main (void)
    {
     // declare variables
     int choice, days;
     float rate, meds, tests;
    // In or out paitent
    
    cout << "If the pateing was an in paiten please press 1 \n";
    cout << "If the patien was an out paitent please press 2 \n";
    cin >> choice;
    //enter values
    switch (choice)
     {
      case 1:
       cout << "Please enter number of days patient was in hospital\n";
       cin >> days;
       cout << "Please enter the daily rate\n";
       cin >> rate;
       cout << "Please enter any medication charges recived\n";
       cin >> meds;
       cout << "Please enter charges for any labs or tests\n";
       cin >> tests;
       total (days, rate, meds, tests);
      break;
    
    
      case 2:
       cout << "Please enter any charges for labs or tests\n";
       cin >> tests;
       cout << "Please enter any charges for medication\n";
       cin >> meds;
       total (meds, tests);
      break;
    
     }
     system("pause");
     return 0;
    }
    
    // in patient total
    void total (int days, float rate, float meds, float tests)
    {
      float daysubtotal, total;
    daysubtotal = days * rate;
    total = daysubtotal + meds + tests;
    cout << "days " << days << endl;
    cout << "at a rate of " << rate << endl;
    cout << "sub total " << daysubtotal << endl;
    cout << "medication " << meds << meds << endl;
    cout << "labs and tests " << tests <<endl;
    cout << "your total comes to " << total << endl;
    }
    
    // out patient
    void total (float tests, float meds)
    {
    float total;
    total = tests + meds;
    cout << "Medication " << meds << endl;
    cout << "Labs and Test " << tests << endl;
    cout << "your total comes to " << total << endl;
    }
    updated now i jsut need to make the input two overloaded functions ill fix the total thing
     
  4. samm

    samm Next in Line

    Joined:
    Dec 22, 2000
    Messages:
    2,630
    Likes Received:
    0
    Location:
    San Jose, CA
    You go to Iowa State don't you? What class is this for? I can help but I don't understand your question.
     
  5. flynfrog

    flynfrog Cool isnt Cheap

    Joined:
    Jul 16, 2001
    Messages:
    6,620
    Likes Received:
    6
    Location:
    Utah
    its for cs207 i handed in a few weeks ago but ill proaby need help this week too
     

Share This Page