Click here to Skip to main content
15,898,373 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalmfc control variable problem Pin
Qraven1-Feb-04 9:18
Qraven1-Feb-04 9:18 
GeneralRe: mfc control variable problem Pin
Qraven1-Feb-04 9:22
Qraven1-Feb-04 9:22 
GeneralRe: mfc control variable problem Pin
Michael P Butler1-Feb-04 9:37
Michael P Butler1-Feb-04 9:37 
GeneralRe: mfc control variable problem Pin
Qraven1-Feb-04 9:57
Qraven1-Feb-04 9:57 
GeneralBitmaps again! Pin
Dennis L1-Feb-04 9:10
Dennis L1-Feb-04 9:10 
GeneralRe: Bitmaps again! Pin
CodeBrain2-Feb-04 0:42
CodeBrain2-Feb-04 0:42 
GeneralRe: Bitmaps again! Pin
John R. Shaw2-Feb-04 1:29
John R. Shaw2-Feb-04 1:29 
GeneralCharacters Pin
seth.jackson1-Feb-04 9:03
seth.jackson1-Feb-04 9:03 
How can I get the program below to reject anything but numbers when the program requests a number?

//Calculator program

#include <iostream>

using namespace std;

int main ()
{ long double var1;
long double var2;
char sign;

//Begin calculator loop. Will loop continuously until first
//number entered is a 0.

do {
cout << "Enter a number ";
cin >> var1;
cout << "Enter a sign ";
cin >> sign;
cout << "Enter a number ";
cin >> var2;

//The function that rejects anything but numbers here

//Begin calculator functions. +, -, /, *.

switch (sign){
case ('+'):
cout << var1 + var2 << '\n' << '\n';
break;
case ('-'):
cout << var1 - var2 << '\n' << '\n';
break;
case ('*'):
cout << var1 * var2 << '\n' << '\n';
break;
case ('/'):
cout << var1 / var2 << '\n' << '\n';
break;
default:
cout << "You didn't enter a correct sign";
cout << '\n' << '\n';
break;
//If the user enters an unrecognized sign they will get a
//message that says: You ddn't enter a correct sign.

}

} while (var1 != 0); //If first number entered is a 0
//the program will terminate at the end
//of the loop. (The Do While loop)
}
GeneralRe: Characters Pin
Robert A. T. Káldy2-Feb-04 13:46
Robert A. T. Káldy2-Feb-04 13:46 
GeneralC++ Question. Pin
WREY1-Feb-04 9:00
WREY1-Feb-04 9:00 
GeneralRe: C++ Question. Pin
Ryan Binns1-Feb-04 17:19
Ryan Binns1-Feb-04 17:19 
GeneralRe: C++ Question. Pin
WREY2-Feb-04 1:34
WREY2-Feb-04 1:34 
GeneralAnother MFC Question Pin
Dev5781-Feb-04 8:57
Dev5781-Feb-04 8:57 
GeneralRe: Another MFC Question Pin
Diddy1-Feb-04 9:03
Diddy1-Feb-04 9:03 
GeneralRe: Another MFC Question Pin
Dev5781-Feb-04 9:45
Dev5781-Feb-04 9:45 
GeneralRe: Another MFC Question Pin
Roger Wright1-Feb-04 10:44
professionalRoger Wright1-Feb-04 10:44 
GeneralRe: Another MFC Question Pin
Roger Allen2-Feb-04 0:53
Roger Allen2-Feb-04 0:53 
General&quot;Volume Control&quot; question Pin
User 66581-Feb-04 8:31
User 66581-Feb-04 8:31 
GeneralRe: &quot;Volume Control&quot; question Pin
Michael P Butler1-Feb-04 9:06
Michael P Butler1-Feb-04 9:06 
GeneralRe: &quot;Volume Control&quot; question Pin
Diddy1-Feb-04 9:10
Diddy1-Feb-04 9:10 
GeneralThanks! Pin
User 66581-Feb-04 9:20
User 66581-Feb-04 9:20 
GeneralProblem With Making New Project Pin
Rassul Yunussov1-Feb-04 7:48
Rassul Yunussov1-Feb-04 7:48 
GeneralRe: Problem With Making New Project Pin
Michael P Butler1-Feb-04 8:07
Michael P Butler1-Feb-04 8:07 
GeneralRe: Problem With Making New Project Pin
anonimous1-Feb-04 22:52
anonimous1-Feb-04 22:52 
GeneralRe: Problem With Making New Project Pin
Michael P Butler1-Feb-04 22:58
Michael P Butler1-Feb-04 22:58 

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.