Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I am writing my final project for my intro to problem solving and algorithm design class and I'm having a bit of trouble correcting it. I submitted it last week and I received some feedback from my professor, but I'm a little lost. Here's the psuedccodoe and design that I wrote:

Design


Main 

Declare variables
Initialize variables

    Start for (count=0; count<49; count++)

Write (Please enter Name of family member)
     Input and store FN 

Write (Please enter Age of family member)
     Input and store FA

Wite (please enter Relation of family member)
      Input and store FR

Write (Please enter State of family member)
       Input and store FS

Write ("The FN of person" + count ": is" + FN[count]" and their FR to you is 			"+ FR[count] " they are FA years old" + count ": is" + FA[count]" and they reside     in FS + count" is"+ FS[count]).

End for 

Subprogram to calculate and display the average age and assign it to the correct count

Write ("Please enter State of family Member")
           Input FS
              Set FS[count]=count

Write ("The FN of person" + count ": is" + FN[count]" and their FR to you is 			"+ FR[count] " they are FA years old" + count ": is" + FA[count]" and they reside     in FS + count" is"+ FS[count]).

End for 


Subprogram to print the names of who reside in Texas or New York

Declare States
Declare count integer
    Set State = 0
      Set count= 0

Start for (count= 0; count< 49; count++)
 
       If (States == Texas or == New York)
       
          Write Names[count]
                 Set count = 1
        
Elseif (States != Texas or != New York)
          Write "No family members reside in Texas or New York."
      
         End If

   End For

End 





Psuedocode

/*This program will prompt the user to input the value of 50 family members*/ /*age, relation, and their state*/
/*The output will print the average of each family members age and those who*/ /*reside in Texas and New York*/
/*Developer: Tiffany Ring*/
/*Date: 08/03/2014*/ 


Main 

/*Declare variables*/

Declare FN[50] as string
Declare FS[50] as string
Declare FA[50] as integer
Declare count as integer
Declare avgA and integer


/*Initialize variables*/

Set count = 0
Start for (count=0; count<49;count++) loop


Write ("Please enter Name of family member")
        Input FN
             Set FN[count]=count


Write ("Please enter Age of family member")
         Input FA
             Set FA[count]=count

Write (Please enter Relation of family member")
          Input FR
             Set FR[count]=count


Write ("Please enter State of family Member")
           Input FS
              Set FS[count]=count

Write ( FN" + count ": is" + FN[count]" who is your FR is "+ FR[count] " they are FA years old" + count ": is" + FA[count]" resides in FS + count" is"+ FS[count]).

End for 


//avgA module - This subprogram will calculate and display the average age and //assign it to the correct count

Declare Sum as integer
Declare Ages as integer 
 Declare count as integer
    Set Sum = 0
      Set Ages = 0
         Set count -0

//The For loop will display the sum of all ages 

    Start for (count=0; count<49;count++)
  
        Set Sum = Sum + Ages[count)
  
           Set Ages = Ages + 1

              Set avgA = Sum/count
End for


//Print data - This subprogram will print the names of who reside in Texas or New //York

Declare States
Declare count integer
    Set State = 0
      Set count= 0

Start for (count= 0; count< 49; count++)
 
       If (States == Texas or == New York)
       
          Write Names[count]
                 Set count = 1
        
Elseif (States != Texas or != New York)
          Write "No family members reside in Texas or New York."
      
         End If

   End For

End 


End 


Here is the feedback that I received from my professor:
Analysis is OK. Design is OK, except you need to call the Subprograms from the Main, You have just Defined them. Psuedo-code: Your arrays are Declared OK. But you assign them to the wrong variable Set FN[count]=count count is an integer counter not the Name the user input. You need to have Input FN[count] - this reads the user entry into the array FN for that particular element. You haven't defined properly your Function or Subprogram with the appropriate command. You need something like Function averAge( Integer Ages[50], Integer count) as Float Likewise for the DisplayStates function. Your Test Plan does not show what your program displays.

Any help or suggestions would be greatly appreciated as I now how to write the pseudo code and design above in a ASCII file
Posted
Updated 10-Aug-14 21:48pm
v2
Comments
[no name] 10-Aug-14 12:48pm    
A suggestion about what? Your professor already gave you the suggestions you need. You just need to go do what he told you to do.
Sergey Alexandrovich Kryukov 10-Aug-14 13:51pm    
If your think some professor gave you insufficient feedback, why looking for another professor? Why not asking the same person to clarify?
Especially when you own information is far from being comprehensive. Essentially, you just dumped some code, without any explanation of what it should do.
—SA

1 solution

For example, in the code:
Write ("Please enter Name of family member")
        Input FN
             Set FN[count]=count

You are trying to read some text into a variable called FN, but you previously declared FN as a 50 element array of strings, so you cannot read into it in this way. You need to declare a different local variable toreceive the input. You then set element FN[count] to the value of count. But, as previously mentioned, FN is an array of strings, you cannot store numbers into it. And why would you, what purpose would that value have in later parts of the program?

You also have references to a variable called FR which has not been declared anywhere.

You will find it much more helpful to use meaningful names for your variables so you can see immediately what each represents.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900