Same project as before but now I have diffrent Errors. fatal error C1075 and error C2450.

//Project 7.4. Program determines what your weight would be on another planet.2.3.
#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:{
cout  << "You're weight would be "<<Mercury<< " on Mercury. \n" ;
break ;

case 2: 
cout  << "You're weight would be "<<Venus<< " on Venus. \n" ;
break ;

case 3: 
cout <<  "You're weight would be "<<Mars<< " on Mars. \n"  ;
break ;

case 4:
cout << "You're weight would be "<<Jupiter<< " on Jupiter. \n" ;
break ;

case 5:
cout << "You're weight would be "<<Saturn<< " on Saturn. \n" ;
break ;

case 6:
cout  << "You're weight would be "<<Uranus<< " on Uranus. \n" ;
break ;

case7:
cout << "You're weight would be "<<Neptune<< " on Neptune. \n" ;
break ;

case 8:
cout << “You're weight would be " <<Pluto<< " on Pluto. \n" ;
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(35) : error C2450: switch expression of type 'double' is illegal
1>        Integral expression required
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(71) : fatal error C1075: end of file found before the left brace '{' at 'g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(11)' was matched
1>Build log was saved at "file://g:\Visual Studio 2008\Projects\Project_7_4\Debug\BuildLog.htm"
1>Project_7_4 - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Recommended Answers

All 4 Replies

See in line 36, there is a brace, remove it, its not required.

Line 65, its double inverted comma, see its not in green color.

Also all the variables Mercury, venus etc are int, but you are multiplying an double to get its value, so it gives you warning converting to int from double.

I fixed what you said but the two original errors are still there.

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

#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:
        cout  << "You're weight would be "<<Mercury<< " on Mercury. \n" ;
    break ;

    case 2: 
        cout  << "You're weight would be "<<Venus<< " on Venus. \n" ;
    break ;

    case 3: {
        cout <<  "You're weight would be "<<Mars<< " on Mars. \n"  ;
    break ;

    case 4:
        cout << "You're weight would be "<<Jupiter<< " on Jupiter. \n" ;
    break ;

    case 5:
        cout << "You're weight would be "<<Saturn<< " on Saturn. \n" ;
    break ;         

    case 6:
        cout  << "You're weight would be "<<Uranus<< " on Uranus. \n" ;
    break ;

    case 7:
        cout << "You're weight would be "<<Neptune<< " on Neptune. \n" ;
    break ;

    case 8:
        cout << "Your weight would be " <<Pluto<< " on Pluto. \n" ; 
    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(26) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(27) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
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(71) : fatal error C1075: end of file found before the left brace '{' at 'g:\visual studio 2008\projects\project_7_4\project_7_4.cpp(11)' was matched
1>Build log was saved at "file://g:\Visual Studio 2008\Projects\Project_7_4\Debug\BuildLog.htm"
1>Project_7_4 - 1 error(s), 8 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
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.