Thread: HELP! can't find that one error in my code

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    1

    HELP! can't find that one error in my code

    run compiler w/o precompiled headers

    i cant find that darn ";" bug, can ya bros help? Thanks

    #include <cmath>
    #include <iostream>
    using namespace std;

    //Function prototype for hat size
    double calc_hat_size(int weight, int height);

    //Funtion prototype for jacket size
    double calc_jacket_size(int height, int weight, int age);

    //Function prototype for waist size
    double calc_waist_size(int weight, int age);

    //Function prototype for show results
    void show_results(double hat, double jacket, double waist);



    int main()
    {

    //boolean condition set to false
    bool cont = false;

    //Intialized variables
    char answer = 'y';

    int age, height, weight;

    double hat_size, jacket_size, waist_size;

    do{

    cout << "Please input in your height in inches: " << endl;
    cin >> height;
    cout << endl;

    cout << "Please input your weight in pounds: " << endl;
    cin >> weight;
    cout endl;

    cout << "Please input your age: " << endl;
    cin >> age;
    cout << endl;

    //Function calls
    hat_size = calc_hat_size(weight, height);

    jacket_size = calc_jacket_size(height, weight, age);

    waist_size = calc_waist_size(weight, age);

    show_results(hat_size, jacket_size, waist_size);

    cout << "Continue (y/n) ? ";
    cin >> answer;
    cont = (answer == 'y');

    //End while
    }while(cont);

    return 0;
    }

    /*********************************************/
    //Function calc_hat_size()
    double calc_hat_size(int weight, int height){

    double const HAT_CONST = 2.9;

    return((weight/height) * HAT_CONST);

    }
    /*********************************************/

    /************************************************** ******/
    //Function calc_jacket_size
    double calc_jacket_size(int height, int weight, int age){

    double const JACKET_CONST = 288.0;
    double value, rv;

    if(age > 39){

    value = (height * weight) / JACKET_CONST + .125;

    rv = value;
    }

    if(age < 40){

    value = (height * weight) / JACKET_CONST;

    rv = value;
    }

    return(rv);
    }
    /*******************************************/

    /*******************************************/
    //Function calc_waist_line()
    double calc_waist_size(int weight, int age){

    double const WEIGHT_CONST = 5.7;
    double value, rv;

    if(age > 29){

    value = (weight/WEIGHT_CONST) + .1;
    rv = value;
    }

    if(age < 30){

    value = (weight/WEIGHT_CONST);
    rv = value;
    }

    return(rv);

    }
    /********************************************/

    /********************************************/
    //Function show_results()
    void show_results(double hat, double jacket, double waist){

    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(1);

    cout << "Your hat size is: " << hat << endl;
    cout << "Your jacket size is: " << jacket << endl;
    cout << "Your waist size is: " << waist << endl;

    return;

    }
    /********************************************/

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    22
    Copy this code into your source... when I ran it, it had 4 errors, I fixed them and it ran just fine...

    #include <cmath>
    #include <iostream>
    using namespace std;

    //Function prototype for hat size
    double calc_hat_size(int weight, int height);

    //Funtion prototype for jacket size
    double calc_jacket_size(int height, int weight, int age);

    //Function prototype for waist size
    double calc_waist_size(int weight, int age);

    //Function prototype for show results
    void show_results(double hat, double jacket, double waist);



    int main()
    {

    //boolean condition set to false
    bool cont = false;

    //Intialized variables
    char answer = 'y';

    int age, height, weight;

    double hat_size, jacket_size, waist_size;

    do{

    cout << "Please input in your height in inches: " << endl;
    cin >> height;
    cout << endl;

    cout << "Please input your weight in pounds: " << endl;
    cin >> weight;
    cout << endl;

    cout << "Please input your age: " << endl;
    cin >> age;
    cout << endl;

    //Function calls
    hat_size = calc_hat_size(weight, height);

    jacket_size = calc_jacket_size(height, weight, age);

    waist_size = calc_waist_size(weight, age);

    show_results(hat_size, jacket_size, waist_size);

    cout << "Continue (y/n) ? ";
    cin >> answer;
    cont = (answer == 'y');

    //End while
    }while(cont);

    return 0;
    }

    /*********************************************/
    //Function calc_hat_size()
    double calc_hat_size(int weight, int height){

    double const HAT_CONST = 2.9;

    return((weight/height) * HAT_CONST);

    }
    /*********************************************/

    /**************************************************
    ******/
    //Function calc_jacket_size
    double calc_jacket_size(int height, int weight, int age){

    double const JACKET_CONST = 288.0;
    double value, rv;

    if(age > 39){

    value = (height * weight) / JACKET_CONST + .125;

    rv = value;
    }

    if(age < 40){

    value = (height * weight) / JACKET_CONST;

    rv = value;
    }

    return(rv);
    }
    /*******************************************/

    /*******************************************/
    //Function calc_waist_line()
    double calc_waist_size(int weight, int age){

    double const WEIGHT_CONST = 5.7;
    double value, rv;

    if(age > 29){

    value = (weight/WEIGHT_CONST) + .1;
    rv = value;
    }

    if(age < 30){

    value = (weight/WEIGHT_CONST);
    rv = value;
    }

    return(rv);

    }
    /********************************************/

    /********************************************/
    //Function show_results()
    void show_results(double hat, double jacket, double waist){

    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(1);

    cout << "Your hat size is: " << hat << endl;
    cout << "Your jacket size is: " << jacket << endl;
    cout << "Your waist size is: " << waist << endl;

    return;

    }
    /********************************************/
    <^>( * ; * )<^>

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. code to find th square root of a number
    By CODY21 in forum C++ Programming
    Replies: 34
    Last Post: 10-29-2010, 09:27 AM
  2. Replies: 12
    Last Post: 06-08-2005, 11:23 AM
  3. << !! Posting Code? Read this First !! >>
    By kermi3 in forum C# Programming
    Replies: 0
    Last Post: 10-14-2002, 01:26 PM
  4. Code to find the day type of day in the year?
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 04-01-2002, 08:58 PM
  5. << !! Posting Code? Read this First !! >>
    By biosx in forum C++ Programming
    Replies: 1
    Last Post: 03-20-2002, 12:51 PM