Programing assignment HELP!!!!

i cant figure out why i get a syntax error with the line " jedi_calc = static_cast (mcc * age) / (weight * weight);"
help please!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
  #include <iostream>
using namespace std;

    // TODO - write a void function that will print out this welcome message
    void intro ()
    {cout << "Welcome to my fabulous Jedi power level calculator!" << endl
         << "This program will take your age, weight, and" << endl
         << "midichlorean count and return your Jedi power level!"
         << endl << endl;
    }
double jedi_power();

int main()
{

    double jedi_level;

    intro ();

    jedi_level = jedi_power ();

    // this should remain inside your main function
    cout << "Your Jedi Level is : " << jedi_level;

    return 0;
}
    // TODO - write a function that will prompt the user for his/her age,
    // weight, and midicholrean count. Then calculate and return their
    // jedi level (returns a double). Remember to assign the retuned value
    // to the variable 'jedi_level'.

    double jedi_power()
    {
    double jedi_calc;

    int age;
    int weight;
    int mcc;
    cout << "please enter your age : ";
    cin >> age;
    cout << "please enter your weight : ";
    cin >> weight;
    cout << "please enter your midicholrean count : ";
    cin >> mcc;

    jedi_calc = static_cast (mcc * age) / (weight * weight);

    return jedi_calc;
    }
You're missing the <type> in your static_cast.

 
jedi_calc = static_cast<double> (mcc * age) / (weight * weight);


http://www.cplusplus.com/doc/tutorial/typecasting/
Last edited on
Topic archived. No new replies allowed.