Hi all...
I have made this program that'll read the letter A, and the numbers 21 and
3.142 from the keyboard.
It all seem to work well, and it compils just fine (no errors), but when I
type in 3.142, I get the error that I didn't type that:
sco-systems:~/work/code# input1
This program read's A, 21 and 3.142 from the keyboard using cin.
Please type the letter A on your keyboard, and hit enter: A Please enter the
number 21 on your keyboard, and hit enter: 21 Please enter the number 3.142
on your keyboard, and hit enter: 3.142
I said 3.142!
sco-systems:~/work/code#
You see what I mean?
Her's the source code:
/*
A program that read's A, 21 and 3.142 from the keyboard using cin. Then it
prints it out to the screen using cout.
*/
#include
void main()
{
char letter;
int number;
float pi;
cout << "\nThis program read's A, 21 and 3.142 from the keyboard
sing
cin.\n";
cout << "\nPlease type the letter A on your keyboard, and hit enter:
";
cin >> letter;
cout << "Please enter the number 21 on your keyboard, and hit enter:
";
cin >> number;
cout << "Please enter the number 3.142 on your keyboard, and hit
enter:
";
cin >> pi;
if (letter == 'a')
cout << "\nPlease use a BIG A the next time!\n\n";
else
if (letter != 'A')
cout << "\nI said an A!\n\n";
else
if (number != 21)
cout << "\nI said 21!\n\n";
else
if (pi != 3.142)
cout << "\nI said 3.142!\n\n";
else
if ((letter == 'A') && (number == 21) && (pi == 3.142))
{
cout << "\n\nYou typed in this:\n";
cout << " " << letter << "\n";
cout << " " << number << "\n";
cout << " " << pi << "\n\n";
}
}
Can you help me? If you can, then thanx...
__ __ __ __ _ _
/_ // / // ///\// email: cfelde@online.no
_ _ __ __//_ /_//_//_/// homepage: http://home.sol.no/~cfelde/
--- BBBS/L v3.33 How
---------------
* Origin: Fluxpod Information eXchange, telnet://fix.no (2:210/30)
|