0 Members and 1 Guest are viewing this topic.
//Main Module - Declare VariablesDeclare Names[50] As StringDeclare Ages[50] As IntegerDeclare State[50] As StringDeclare MemberName, Residency As StringDeclare MemberAge, Count As IntegerDeclare AgeAvg As Float Call Welcome_Message moduleCall Input moduleEnd Program//Input module - request necessary inputsSet Count = 0 Write "Enter a family member's name; Enter * when done."Input MemberNameWhile MemberName != "*" Set Names[Count] = MemberName Write "Enter this family member's age: " Input MemberAge[Count] Set Ages[Count] = MemberAge Write "Enter this family member's state of residency: " Input Residency Set State[Count] = Residency Set Count = Count + 1 Write "Enter a family member's name or * when done." Input MemberNameEnd While(MemberName)Call Age_Average moduleCall Texas_Residents module//Age_Average module - This submodule will produce the average family age//and display it to the user.Declare Sum As IntegerDeclare K As Integer Set Sum = 0Set K = 0//The While loop below will get the sum of all ages While K < Count Set Sum = Sum + Ages[K] Set K = K + 1End While//The below computes the age average and set its corresponding value to the variable. Set AgeAvg = Sum/Count //Texas_Residents module - This submodule will determine which family//members reside in Texas and display their names.If State == "Texas" Then Write "The following family members live in Texas: " Write Names[50] Else Write "No family member lives in Texas."End If
I will help you to finish your program as soon as I finish all of my unfinished programs
Do you want someone to code it? Or just help you finish it? or what? I dont understand at all
you already keeping track of the count, use a for loop to compare the "state[count]" variable with the word "Texas" if it finds it then display the name variable "Names[Count]"what language you will code in ?
For (State[Count] = 1; State[Count] == Texas; State[Count++]) Write "The following family members live in Texas: " Write Names[Count]End For
for ( int x = 0; x <= Count; x++ ) { if ( State[x] == "Texas" ) cout << Names[x] << "\n";}
Declare Index As IntegerDeclare Found As IntegerSet Index = 0Set Found = 0While (Found == 0) AND (Index < Count) If State[Index] == "Texas" Then Set Found = 1 End If Set Index = Index + 1End WhileIf Found == 0 Then Write "No Family members reside in Texas."Else Write "Following family members reside in Texas: " Write Names[Index - 1]End If
Declare Index As IntegerDeclare Found As IntegerSet Index = 0Set Found = 0While (Index < Count) If State[Index] == "Texas" Then Set Found = 1 write Names[Index]End WhileIf Found == 0 Then Write "No Family members reside in Texas."
No Family members reside in Texas.No Family members reside in Texas.KoubaKNo Family members reside in Texas.Rav3n
Declare K As IntegerSet K = 0For (K = 0; K < Count; K++) If State[K] == "Texas" Then Set Found = 1 End If Set K = K + 1End For
set found = 1
write Names[k]
K = K + 1