Valid user entries are:
- 'C' for Cotton
- 'L' for Liner
- 'P' for Polyester
Prompt:
Enter the fabric code found on your pants:
Possible Output:
Your pants contain cotton. Air dry to avoid shrinking!
Your pants contain linen. They are cool but wrinkle easily!
Your pants contain polyester. They are stain resistant!
Invalid fabric code. Please run the program again.
Notes and Hints:
1) You must accept the upper or lowercase version of the letters. Use whatever method you want of handling this.
#include <iostream>
using namespace std;
int main() {
char fabricCode;
cout << "Enter the fabric code found on your pants: ";
cin >> fabricCode;
switch (fabricCode) {
case 'C':
case 'c':
cout << "Your pants contain cotton. Air dry to avoid shrinking!\n";
break;
case 'L':
case 'l':
cout << "Your pants contain linen. They are cool but wrinkle easily!\n";
break;
case 'P':
case 'p':
cout << "Your pants contain polyester. They are stain resistant!\n";
break;
default:
cout << "Invalid fabric code. Please run the program again.\n";
}
return 0;
}
Comments
Leave a comment