Click here to Skip to main content
15,891,033 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Successful Debug Build, but got Errors during Release Build Pin
PankajB4-Apr-09 2:44
PankajB4-Apr-09 2:44 
GeneralRe: Successful Debug Build, but got Errors during Release Build Pin
Joseph Marzbani4-Apr-09 4:02
Joseph Marzbani4-Apr-09 4:02 
QuestionIs it possible to get individual properties from a specific Flag value in VC++? Pin
Joseph Marzbani3-Apr-09 20:55
Joseph Marzbani3-Apr-09 20:55 
QuestionHelp Please!!! Pin
angel.monkey3-Apr-09 20:54
angel.monkey3-Apr-09 20:54 
AnswerRe: Help Please!!! Pin
Joseph Marzbani3-Apr-09 21:03
Joseph Marzbani3-Apr-09 21:03 
GeneralRe: Help Please!!! Pin
angel.monkey3-Apr-09 21:14
angel.monkey3-Apr-09 21:14 
AnswerRe: Help Please!!! - Warning, long reply! Pin
Iain Clarke, Warrior Programmer3-Apr-09 23:16
Iain Clarke, Warrior Programmer3-Apr-09 23:16 
AnswerRe: Help Please!!! Pin
Rajesh R Subramanian3-Apr-09 23:22
professionalRajesh R Subramanian3-Apr-09 23:22 
Since you say you've been trying it for days, I'll give you a solution. But try and understand where you've gone wrong.
#include <iostream>
using namespace std;

#define PLANET_MERCURY 1
#define PLANET_VENUS   2

int main (void)
{
float fMultiplier = 1, fWeight = 1;
unsigned int nPlanet = 0;

cout<<"Please enter your weight"<<endl;
cin>>fWeight;

cout<<"Please choose a planet from the following (enter corresponding number)"<<endl;
cout<<"1. Mercury"<<endl<<"2. Venus"<<endl;
cin>>nPlanet;

switch(nPlanet)
{
case PLANET_MERCURY: fMultiplier = 0.4155; 
                     cout<<"Your weight in Mercury is: "; 
                     cout<<fWeight*fMultiplier<<endl;
                     break;

case PLANET_VENUS:   fMultiplier = 0.8975; 
                     cout<<"You weight in Venus is: "; 
                     cout<<fWeight*fMultiplier<<endl;
                     break;

default:             cout<<"Invalid choice!"<<endl;
                     break;
}

return 0;
}

Try to understand how the program works and then you can do it for the rest of the planets. You're still just beginning and you can very well read up a book. Master the fundamentals well and now. Or, you'll have trouble later.

Not the usage of >> with cin and << with cout. Note the switch cases enclosed in braces { } and can have a default case handler too.


It is a crappy thing, but it's life -^ Carlo Pallini

GeneralRe: Help Please!!! Pin
Iain Clarke, Warrior Programmer3-Apr-09 23:28
Iain Clarke, Warrior Programmer3-Apr-09 23:28 
GeneralRe: Help Please!!! Pin
Rajesh R Subramanian3-Apr-09 23:35
professionalRajesh R Subramanian3-Apr-09 23:35 
GeneralOT - Re: Help Please!!! Pin
Iain Clarke, Warrior Programmer3-Apr-09 23:47
Iain Clarke, Warrior Programmer3-Apr-09 23:47 
GeneralRe: OT - Re: Help Please!!! Pin
Rajesh R Subramanian4-Apr-09 0:45
professionalRajesh R Subramanian4-Apr-09 0:45 
GeneralRe: OT - Re: Help Please!!! [modified] Pin
angel.monkey4-Apr-09 10:06
angel.monkey4-Apr-09 10:06 
GeneralRe: OT - Re: Help Please!!! Pin
Iain Clarke, Warrior Programmer5-Apr-09 22:31
Iain Clarke, Warrior Programmer5-Apr-09 22:31 
GeneralRe: Help Please!!! [modified] Pin
Sauce!4-Apr-09 17:00
Sauce!4-Apr-09 17:00 
GeneralRe: Help Please!!! Pin
Rajesh R Subramanian5-Apr-09 2:49
professionalRajesh R Subramanian5-Apr-09 2:49 
QuestionUSB Drive Pin
MsmVc3-Apr-09 18:23
MsmVc3-Apr-09 18:23 
AnswerRe: USB Drive Pin
Iain Clarke, Warrior Programmer3-Apr-09 23:29
Iain Clarke, Warrior Programmer3-Apr-09 23:29 
QuestionHow can i call a function with a CString variable ? Pin
SNArruda3-Apr-09 16:57
SNArruda3-Apr-09 16:57 
AnswerRe: How can i call a function with a CString variable ? Pin
Divyang Mithaiwala3-Apr-09 21:16
Divyang Mithaiwala3-Apr-09 21:16 
AnswerRe: How can i call a function with a CString variable ? Pin
Iain Clarke, Warrior Programmer3-Apr-09 23:41
Iain Clarke, Warrior Programmer3-Apr-09 23:41 
Question_beginthreadex() conversion error Pin
Killiconn3-Apr-09 15:42
Killiconn3-Apr-09 15:42 
AnswerRe: _beginthreadex() conversion error Pin
sashoalm4-Apr-09 2:17
sashoalm4-Apr-09 2:17 
AnswerRe: _beginthreadex() conversion error Pin
Stuart Dootson4-Apr-09 2:48
professionalStuart Dootson4-Apr-09 2:48 
QuestionStrategy Question Pin
Parker M cCauley3-Apr-09 13:40
Parker M cCauley3-Apr-09 13:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.