需要帮助psuedocode和设计...... [英] Need help with psuedocode and design…

查看:128
本文介绍了需要帮助psuedocode和设计......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的问题解决和算法设计课程的介绍编写我的最终项目,我在纠正它时遇到了一些麻烦。我上周提交了它,我收到了我教授的一些反馈,但我有点失落。这是我写的psuedccodoe和设计:



设计





 Main 

声明变量
初始化变量

开始(count = 0; count< 49; count ++)

写信(请输入家庭成员姓名)
输入和储存FN

写信(请输入家庭成员年龄)
输入和储存FA

Wite(请输入家庭成员的关系)
输入和存储FR

写信(请输入家庭成员的状态)
输入和储存FS

写(人的FN+计数:是+ FN [计数],他们的FR是+ FR [计数]他们是FA岁+计数:是+ FA [count]和它们驻留在FS +计数是+ FS [计数]。

结束

子程序计算并显示平均年龄并分配它正确计数

写(请输入家庭成员国)
输入FS
设置FS [计数] =计数

写(人的FN+计数:是+ FN [计数],他们的FR是+ FR [计数]它们是FA岁+计数:是+ FA [计数]并且它们位于FS +计数是+ FS [计数])。

结束


子程序打印居住在德克萨斯州或纽约州的人姓名

申报国
申报count integer
Set State = 0
Set count = 0

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

If(States ==德克萨斯或==纽约)

写名[count]
设定数= 1

Elseif(州!=德克萨斯州或!=纽约州)
写道没有家庭成员居住在德克萨斯州或纽约州。

结束如果

结束

结束











 Psuedocode 

/ *此程序将提示用户输入50个家庭成员的价值* / / *年龄,关系及其州* /
/ *输出将打印每个家庭成员年龄和* / / *居住在德克萨斯州的人的平均值纽约* /
/ *开发商:Tiffany Ring * /
/ *日期:08/03/2014 * /


主要

/ *声明变量* /

声明FN [50]为字符串
将FS [50]声明为字符串
将FA [50]声明为整数
声明计数为整数
声明avgA和整数


/ *初始化变量* /

设置计数= 0
开始(count = 0;计数< 49;计数++)循环


写(请输入家庭成员姓名)
输入FN
设置FN [count] = count


写(请输入家庭成员年龄)
输入FA
设置FA [count] = count

写(请输入家庭成员的关系)
输入FR
设置FR [count] = count


写(请输入家庭成员国)
输入FS
设置FS [count] = count

写入(FN+计数:是+ FN [计数]谁是你的FR是+ FR [计数]他们是FA岁+计数:是+ FA [计数]驻留在FS +计数是+ FS [COUNT])。

结束为


// avgA模块 - 此子程序将计算并显示平均年龄并//将其分配给正确的计数

声明和为整数
声明年龄为整数
声明计数为整数
设置总和= 0
设置年龄= 0
设置计数-0

// For循环将显示所有年龄的总和

开始(count = 0; count< 49; count ++)

Set Sum = Sum +年龄[计数]

设置年龄=年龄+ 1

设置avgA =总和/计数
结束


//打印数据 - 该子程序将打印居住在德克萨斯州或新约的人的姓名//约克

声明状态
声明计数整数
设置状态= 0
设置计数= 0

开始(count = 0; count< 49; count ++)

If(States == Texas或== New York)

写名[count]
设置数= 1

Elseif(States!= Texas或!= New York)
写下没有家庭成员居住在德克萨斯州或纽约州。

结束如果

结束

结束


结束





以下是我从教授那里得到的反馈意见:

分析还可以。设计没问题,除了你需要从Main调用Subprograms,你刚刚定义了它们。 Psuedo-code:您的数组已声明正常。但是你将它们分配给错误的变量Set FN [count] = count count是一个整数计数器而不是用户输入的Name。您需要输入FN [count] - 这将读取该特定元素的数组FN中的用户条目。您没有使用适当的命令正确定义函数或子程序。对于DisplayStates函数,您需要像函数averAge(整数年龄[50],整数计数)一样的Float。您的测试计划不会显示您的程序显示的内容。



我将非常感谢任何帮助或建议,因为我现在如何在ASCII中编写伪代码和设计file

解决方案

例如,在代码中:

写(请输入家庭成员姓名)
输入FN
设置FN [count] = count



您试图将一些文本读入名为 FN ,但您之前已将 FN 声明为50个元素的字符串数组,因此您无法以这种方式读入它。您需要声明一个不同的局部变量来接收输入。然后,将元素 FN [count] 设置为 count 的值。但是,如前所述, FN 是一个字符串数组,您无法在其中存储数字。为什么你会在程序的后面部分有什么目的呢?



您还引用了一个名为 FR <的变量/ code>尚未在任何地方声明。



您会发现为变量使用有意义的名称会更有帮助,因此您可以立即看到每个变量表示。


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

解决方案

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.


这篇关于需要帮助psuedocode和设计......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆