0 Members and 1 Guest are viewing this topic.
Declare K As IntegerSet K = 0For (K = 0; K < Count; K++) If State[K] == "Texas" Then Write Names[K] Else Write "No family members reside in Texas." End IfEnd For
Rav3n, so it should look something like this:Code: [Select]Declare K As IntegerSet K = 0For (K = 0; K < Count; K++) If State[K] == "Texas" Then Write Names[K] Else Write "No family members reside in Texas." End IfEnd For
Declare K As IntegerDeclare atLeastOnePrinted as booleanSet atLeastOnePrinted = falseSet K = 0For (K = 0; K < Count; K++) If State[K] == "Texas" Then Write Names[K] Set atLeastOnePrinted = true End IfEnd ForIf !atLeastOnePrinted then Write "No family members reside in Texas."end if
bool atLeastOnePrinted = FALSE;for(int i=0;i<=sizeof(States);i++){ if(States[i] == "Texas") { cout << "Person: " << Names[i] << " lives in Texas." << endl; atLeastOnePrinted = TRUE; }}if(!atLeastOnePrinted) cout << "No family members reside in Texas." << endl;
Declare K As IntegerDeclare Found As IntegerSet Found = 0Set K = 0For (K = 0; K < Count; K++) If State[K] == "Texas" Then Write Names[K] Set Found = 1 End IfEnd ForIf Found == 0 then Write "No family members reside in Texas."end if
ande, since I cannot use a boolean (just because it has not been covered in class yet). would introducing Found back into the pseudo work?Code: [Select]Declare K As IntegerDeclare Found As IntegerSet Found = 0Set K = 0For (K = 0; K < Count; K++) If State[K] == "Texas" Then Write Names[K] Set Found = 1 End IfEnd ForIf Found == 0 then Write "No family members reside in Texas."end if
bool atLeastOnePrinted = FALSE;
int atLeastOnePrinted = 0;
atLeastOnePrinted = True;
atLeastOnePrinted = 1;
if(!atLeastOnePrinted) cout << "No family members reside in Texas." << endl;
if(atLeastOnePrinted == 1) cout << "No family members reside in Texas." << endl;