IfTest1

IfTest1 - { cout <<...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// IfTest1.cpp //-------------------------------- #include <iostream> using namespace std; /*------------------ read letter and number: A1-10 -- Group 1 A11-20 -- Group 2 A21-30 -- Group 3 B5-9 -- Group 4 B10-17 -- Group 5 b18-29 -- Group 6 else ILLEGAL GRoup ---------------------*/ - int main() { char letter; int num; cout << "Enter group letter:(A or B) "; cin >> letter; { cout << "Letter must be 'A' or 'B'" << endl; return 0; } cout << "Enter group number:(1-29) "; cin >> num; if( num <= 0 || num > 29 )
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { cout &lt;&lt; &quot;Illegal number&quot; &lt;&lt; endl; return 0; } if( letter == 'A' ) { if( num &lt;= 10 ) cout &lt;&lt; &quot;Group 1&quot; &lt;&lt; endl; else if( num &lt;= 20 ) cout &lt;&lt; &quot;Group 2&quot; &lt;&lt; endl; else if( num &lt;= 30 ) cout &lt;&lt; &quot;Group 3&quot; &lt;&lt; endl; else cout &lt;&lt; &quot;ILLEGAL Group&quot; &lt;&lt; endl; } else { if( num &lt; 5 || num &gt; 29 ) cout &lt;&lt; &quot;ILLEGAL Group&quot; &lt;&lt; endl; else if( num &lt;= 9 ) cout &lt;&lt; &quot;Group 4&quot; &lt;&lt; endl; else if( num &lt;= 17 ) cout &lt;&lt; &quot;Group 5&quot; &lt;&lt; endl; else cout &lt;&lt; &quot;Group 6&quot; &lt;&lt; endl; } return 1 ; }...
View Full Document

Ask a homework question - tutors are online