/*File: Operators01.cpp
This C++ program illustrates the use of the
following relational and logical operators:
<
||
>
This program solves the same problem as the
program named Operators02 but uses a different
formulation of the relational/logical test.
The program displays the following output on the
screen for several user input values:
Enter an upper-case letter: @
Bad input
Enter an upper-case letter: [
Bad input
Enter an upper-case letter: A
Thanks for the A
************************************************/
#include
using namespace std;
class Operators01{
public:
static void classMain(){
Operators01* ptrToObject = new Operators01();
ptrToObject -> doSomething();
}//End classMain function
//-------------------------------------------//
//An instance function of the Operators01 class
void doSomething(){
//Begin sequence structure
//Do a priming read
char temp = 0;
cout << "Enter an upper-case letter: ";
cin >> temp;
//End sequence structure
//Begin loop structure
while((temp < 'A') || (temp > 'Z')){
//Outside allowable character range
cout << "Bad input" << endl;
cout << "Enter an upper-case letter: ";
cin >> temp;
}//end while loop
//End end loop structure
//Good input, display msg and terminate.
cout << "Thanks for the " << temp << endl;
}//end doSomething function
};//End Operators01 class
//---------------------------------------------//
int main(){
Operators01::classMain();
return 0;
}//end main
Listing 5
|