Im in a programing class and my teacher had a heart attack and is away, the supply knows nothing. The project is to create a program using a swtich structure to calculate the weight on a specific planet. I have no i idea if i am doing this right. Can you help?

// Project 7.4. Program determines what your weight would be on another planet.

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

int EarthWeight ;
int WeightOnPlanet, Mercury, Venus, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto ;

int main ()
{

    cout << "What is your weight on Earth? \n" ;
    cin >> EarthWeight ;

    cout << "Which planet would you like to know your weight on? \n" ;
    cout << "1 - Merury. \n" ;
    cout << "2 - Venus. \n" ;
    cout << "3 - Mars. \n" ;
    cout << "4 - Jupiter. \n" ;
    cout << "5 - Saturn. \n" ;
    cout << "6 - Uranus. \n" ;
    cout << "7 - Neptune. \n" ;
    cout << "8 - Pluto. \n" ;
    cout << "Enter the number beside the planet you would like to know. \n" ;
    cin >> WeightOnPlanet ;

    Mercury = EarthWeight * 0.37 ;
    Venus = EarthWeight * 0.88 ;
    Mars = EarthWeight * 0.38 ;
    Jupiter = EarthWeight * 2.64 ;
    Saturn = EarthWeight * 1.15 ;
    Uranus = EarthWeight * 1.15 ;
    Neptune = EarthWeight * 7.72 ;
    Pluto = EarthWeight * 0.04 ;


    switch (WeightOnPlanet)
    {
    case 1:{
            printf ("You're weight would be "<<Mercury<< " on Mercury. \n") ;
            Mercury = EarthWeight * 0.37 ;
        break ;
           }
    case 2: {
            printf ("You're weight would be "<<Venus<< " on Venus. \n") ;
            Venus = EarthWeight * 0.88 ;
        break ;
            }
    case 3: {
            printf ("You're weight would be "<<Mars<< " on Mars. \n") ;
            Mars = EarthWeight * 0.38 ;
        break ;
            }
    case 4:{
            printf ("You're weight would be "<<Jupiter<< " on Jupiter. \n") ;
            Jupiter = EarthWeight * 2.46 ;
        break ;
           }
    case 5:{
            printf ("You're weight would be "<<Saturn<< " on Saturn. \n") ;
            Saturn = EarthWeight * 1.15 ;
        break ;
           }
    case 6:{
            printf ("You're weight would be "<<Uranus<< " on Uranus. \n") ;
            Uranus = EarthWeight * 1.15 ;
        break ;
           }
    case 7:{
            printf ("You're weight would be "<<Neptune<< " on Neptune. \n") ;
            Neptune = EarthWeight * 1.12 ;
        break ;
           }
    case 8:{
            printf ("You're weight would be " <<Pluto<< " on Pluto. \n") ;
            Pluto = EarthWeight * 00.4 ;
        break ;
           }
    }


    return 0 ;
}



Errors:
1>------ Build started: Project: Project_7_4, Configuration: Debug Win32 ------
1>Compiling...
1>Project_7_4.cpp
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(28) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(29) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(30) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(31) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(32) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(33) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(34) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(35) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(41) : error C2296: '<<' : illegal, left operand has type 'const char [24]'
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(42) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(46) : error C2296: '<<' : illegal, left operand has type 'const char [24]'
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(47) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(51) : error C2296: '<<' : illegal, left operand has type 'const char [24]'
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(52) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(56) : error C2296: '<<' : illegal, left operand has type 'const char [24]'
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(57) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(61) : error C2296: '<<' : illegal, left operand has type 'const char [24]'
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(62) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(66) : error C2296: '<<' : illegal, left operand has type 'const char [24]'
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(67) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(71) : error C2296: '<<' : illegal, left operand has type 'const char [24]'
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(72) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(76) : error C2296: '<<' : illegal, left operand has type 'const char [24]'
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(77) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>Build log was saved at "file://g:\Visual Studio 2008\Projects\Project_7_4\Debug\BuildLog.htm"
1>Project_7_4 - 8 error(s), 16 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Member Avatar for SoreComet

Why are you using printf instead of cout?

You have included iostream and have not used cout to print !!
To use printf, use stdio.h header file

warning C4244:

You are getting that because the program is assigning a double to an int -- for example assigning a double value to Mercury. That's not really a problem unless you expect Mercury to have fractions. The way to remove such warnings is to convert the result of the weight calculations into int before assigning to int variable, that's called typecastging. For example: Mercury = (int)(EarthWeight * 0.37);

The error on line 46: You have confused the syntax between printf() and cout. If you want to use printf() then don't use <<.

printf ("You're weight would be %d\n", Venus);

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.