Sunday, September 29, 2019
Final Project
Final Project Part 2(Worth 20% of your grade) Student Name: James Keys Class/Section: CMIS 102 Professor Name: Jose Romero Assignment due date: 11/4/12 // Which State. cpp #include ââ¬Å"stdafx. hâ⬠#include <iostream> #include <string> using namespace std; int main() { int x = 0; int found = 0; int count=0; float sum; float average; int age[10]; string name[10]; string Find_State = ââ¬Å"â⬠; string state[10]; string state_abbr[10]; bool okay = true; do { cout << ââ¬Å"Enter the family member's name. Type ââ¬Ëdone' when complete. ;lt;;lt; endl; cin ;gt;;gt; name[count]; if ( name[count] == ââ¬Å"DONEâ⬠|| name[count]==â⬠doneâ⬠) { okay = false; break; } cout ;lt;;lt; ââ¬Å"Enter family member's ageâ⬠;lt;;lt; endl; cin ;gt;;gt; age[count]; cout ;lt;;lt; ââ¬Å"Which state is â⬠;lt;;lt; name[count] ;lt;;lt; â⬠from? Type in CA, NY, TX, VA, VT? â⬠;lt;;lt; endl; cin ;gt;;gt; state[count]; if ( state[count] == ââ¬Å "CAâ⬠|| state[count] == ââ¬Å"caâ⬠) { state[count] = ââ¬Å"Californiaâ⬠; state_abbr[count] = ââ¬Å"CAâ⬠; }else if (state[count]==â⬠TXâ⬠|| state[count] == ââ¬Å"txâ⬠) { state[count] = ââ¬Å"Texasâ⬠; tate_abbr[count] = ââ¬Å"TXâ⬠; } else if (state[count]==â⬠VAâ⬠|| state[count] == ââ¬Å"vaâ⬠) { state[count] = ââ¬Å"Virginiaâ⬠; state_abbr[count] = ââ¬Å"VAâ⬠; } else if (state[count]==â⬠NYâ⬠|| state[count] == ââ¬Å"nyâ⬠) { state[count] = ââ¬Å"New Yorkâ⬠; state_abbr[count] = ââ¬Å"NYâ⬠; } else if (state[count]==â⬠VTâ⬠|| state[count] == ââ¬Å"vtâ⬠) { state[count] = ââ¬Å"Vermontâ⬠; state_abbr[count] = ââ¬Å"VTâ⬠; } else { cout ;lt;;lt; ââ¬Å"I don't understand!! â⬠;lt;;lt; endl; countââ¬â; } count++; } while (okay || count ! = 10); char yn=' ââ¬Ë; do { cout << ââ¬Å"Do you wish to list people living in a certain state? << en dl; cin >> yn; if ( yn == ââ¬ËY') { cout << ââ¬Å"Enter the state abbreviation : ââ¬Å"; cin >> Find_State; for (x=0;x<count;x++) if (state_abbr[x] == Find_State) { cout << name[x] << â⬠lives in â⬠<< state[x] << endl; found++; } if (! found) { cout << ââ¬Å"Couldn't find anyone living in the state of â⬠<< Find_State << ââ¬Å". â⬠<< endl; } } else if ( yn == ââ¬ËN') cout << ââ¬Å"Okay, we'll continue on!! â⬠<< endl << endl; break; } while (yn ! ââ¬ËY' || yn ! = ââ¬ËN'); sum = 0. 0; average = 0. 0; for ( x=0;x<count;x++) { sum = sum + age[x]; } average = sum/count; cout << endl << endl << ââ¬Å"The average age of your family is â⬠<< average << â⬠years old. â⬠<< endl << endl; cout << ââ¬Å"The entered data was :â⬠<< endl << endl; for ( x=0; x < count ;x++) { cout << name[x] << â⬠lives in â⬠<< state[x] << â⬠and is â⬠<< age[x] << â⬠years old. â⬠<< endl; } return 0;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.