1
Projects and Discussion / Re: Programing Help
« on: May 09, 2013, 11:27:28 PM »
Thanks guys... Once I'm done with my other classes I will use the free time to try to actually code the entire program.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Declare K As Integer
Declare Found As Integer
Set Found = 0
Set K = 0
For (K = 0; K < Count; K++)
If State[K] == "Texas" Then
Write Names[K]
Set Found = 1
End If
End For
If Found == 0 then
Write "No family members reside in Texas."
end if
Declare K As Integer
Set K = 0
For (K = 0; K < Count; K++)
If State[K] == "Texas" Then
Write Names[K]
Else
Write "No family members reside in Texas."
End If
End For
Declare K As Integer
Set K = 0
For (K = 0; K < Count; K++)
If State[K] == "Texas" Then
Set Found = 1
End If
Set K = K + 1
End For
Declare Index As Integer
Declare Found As Integer
Set Index = 0
Set Found = 0
While (Found == 0) AND (Index < Count)
If State[Index] == "Texas" Then
Set Found = 1
End If
Set Index = Index + 1
End While
If Found == 0 Then
Write "No Family members reside in Texas."
Else
Write "Following family members reside in Texas: "
Write Names[Index - 1]
End If
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
Do you want someone to code it? Or just help you finish it? or what? I dont understand at all
I will help you to finish your program as soon as I finish all of my unfinished programs
//Main Module - Declare Variables
Declare Names[50] As String
Declare Ages[50] As Integer
Declare State[50] As String
Declare MemberName, Residency As String
Declare MemberAge, Count As Integer
Declare AgeAvg As Float
Call Welcome_Message module
Call Input module
End Program
//Input module - request necessary inputs
Set Count = 0
Write "Enter a family member's name; Enter * when done."
Input MemberName
While 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 MemberName
End While(MemberName)
Call Age_Average module
Call Texas_Residents module
//Age_Average module - This submodule will produce the average family age
//and display it to the user.
Declare Sum As Integer
Declare K As Integer
Set Sum = 0
Set K = 0
//The While loop below will get the sum of all ages
While K < Count
Set Sum = Sum + Ages[K]
Set K = K + 1
End 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