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? << endl; 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;