Re: C++ Inputs and ASCII
Yah. That was kind of by accident. It's a bit too late now, but I'd like to know anyways.
// Dennis Ai
// CSC133GW
// Lab03.cpp
// This program will determine if the digits of a 3digit number are odd or even.
#include <iostream.h>
#include <iomanip.h>
int main()
{
//local declarations
int Number, HDCalc, TDCalc, UDCalc, TDQuotient, HDQuotient;
int OddCounter, EvenCounter, ZeroCounter;
OddCounter = 0;
EvenCounter = 0;
ZeroCounter = 0;
cout<<"___________________________________________ ___________________________"<<endl;
cout<<"Dennis Ai CSC133GW Lab03ex.cpp 7/11/06"<<endl;
cout<<"___________________________________________ ___________________________"<<endl;
cout<<"This program will calculate if the digits of a threedigit number are"<<endl;
cout<<"odd or even."<<endl;
//Imput digits
cout<<"Please enter your threedigit number: ";
cin>>Number;
//Determine unit digit's odd/even attribute
UDCalc = Number % 2;
if (UDCalc==1)
OddCounter++;
else if (UDCalc==0)
{
UDCalc = Number % 10;
if (UDCalc==0)
ZeroCounter++;
else EvenCounter++;
}
//Determine ten digit's odd/even attribute
TDCalc = Number / 10;
TDQuotient = TDCalc % 2;
if (TDQuotient==1)
OddCounter++;
else if (TDQuotient==0)
{
TDCalc = TDCalc % 10;
if (TDCalc==0)
ZeroCounter++;
else EvenCounter++;
}
//Determine hundred digit's odd/even attribute
HDCalc = Number / 100;
HDQuotient = HDCalc % 2;
if (HDQuotient==1)
OddCounter++;
else if (HDQuotient==0)
{
HDCalc = HDCalc % 10;
if (HDCalc==0)
ZeroCounter++;
else EvenCounter++;
}
//Rewrite threedigit number
cout<<"The threedigit number you entered was: "<<Number<<endl;
//Print out even/odd attribute
if (OddCounter==3)
cout<<"The number contains all odd digits.";
else if (EvenCounter==3)
cout<<"The number contains all even digits.";
else if (ZeroCounter==3)
cout<<"The number contains all zeroes.";
else if ((OddCounter==1) && (EvenCounter==1) && (ZeroCounter==1))
cout<<"The number contains odd, even, and zero digits.";
else if ((OddCounter>=1) && (ZeroCounter>=1))
cout<<"The number contains odd and zero digits.";
else if ((EvenCounter>=1) && (ZeroCounter>=1))
cout<<"The number contains even and zero digits.";
else if ((OddCounter>=1) && (EvenCounter>=1))
cout<<"The number contains both odd and even digits.";
cout<<OddCounter<<EvenCounter<<ZeroCounter;
//End main
return 0;
}
__________________
Athlon FX55 San Diego 2.6GhZ OCed to 3.0GhZ  Mushkin Redline XP 2x1GB PC4000 DDR500 3328 OCed to 250MhZ  Seagate Barracuda SATA 400GB 7200RPM HDD  evGA GeForce 6800GT 350/1000 OCed to 425/1150
