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;

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.