2 Replies - 388 Views - Last Post: 30 August 2013 - 12:33 PM Rate Topic: ***-- 2 Votes

#1 Redxking  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 30-August 13

Question does this Psuducode look righ?

Posted 30 August 2013 - 12:06 PM

I have started my first programming class and in this class we do not compile any code but we are expected to do psudocode. I would like to know if based off my code if I have created code that has done the following;
a. Prompt the user to enter a numeric score.
b. Read the score. Note that fractional inputs (like 95.7) are possible
c. If the score entered is not valid, print an error message, do not assign a grade, and do not output a grade
d. Otherwise, assign a letter grade to a variable based on the grading criteria below
e. Output the letter grade

Score Grade
90-100 A
80 up to but less than 90 B
70 up to but less than 80 C
60 up to but less than 70 D
less than 60 F
less than 0 or greater than 100 invalid score

I am not looking for any free code just want to make sure I have completed my task and that this code is well written.

Thank you.



//Main Module
//Written by A. Pseftis 08/30/2013
//The Main Module first declares all the variables used within the program. Then it gives the //welcome message and name of the program.  Next it gives a description of what the function of //this program is. Lastly it calls all the sub modules to be executed in the order they are listed.
//
Main Module
	Declare Score As Float
	Declare Grade As Character
	Write “Welcome to the score to grade converter”
	Write
Write “This program will take the number value of a score and convert it to it’s 
Write “letter value and displays that value for the user.”
Write
Call Input Data module
Call Process module
Call Results module
End Program

//Input Module
//Written by A. Pseftis 08/30/2013
//Prompts the user to enter the number value of the score they want converted.
//
Input Data module
Write “Please enter the score.”
Input Score
End Input module

//Process module
//Written by A. Pseftis 08/30/2013
//Takes the number value from the input module and converts it into the corresponding //letter value.
//
Process module
	Set Score = Grade
         IF ((Score > 90) AND (Score <= 100)) THEN
            Write “grade:”= 'A'
         If Else ((Score >= 80) AND (Score <= 90)) THEN
            Write “grade:”= 'B'
         If Else ((Score >= 70) AND (Score <= 80)) THEN
            Write “grade:”= 'C'
         If Else ((Score >= 60) AND (Score <= 70)) THEN
            Write “grade:”= 'D'
         If Else ((Score <=60) THEN 
            Write “grade:”= grade: = 'F'
         If Else ((Score < 0) AND (Score >100)) THEN
            Write “grade:”= “invalid score”
   End If
End Process module

//Output Results module
//Written by A. Pseftis 08/30/2013
//Outputs the letter value that was converted from the input score or give the invalid score 
//message if the input was invalid.
Output Results module
	Write “A” +Grade
	Write “B” +Grade
	Write “C” +Grade
	Write “D” +Grade
	Write “F” +Grade
	Write “invalid score” +Grade 
End Output module



Is This A Good Question/Topic? 0
  • +

Replies To: Question does this Psuducode look righ?

#2 DarenR  Icon User is offline

  • D.I.C Lover

Reputation: 433
  • View blog
  • Posts: 3,006
  • Joined: 12-January 10

Re: Question does this Psuducode look righ?

Posted 30 August 2013 - 12:24 PM

pseudo code can be written anyway you want as long as it is understandable.

Though it is usually written closely to what the language that you are using would be.

like

get_user_input()
ask for user input
end sub
use_input()
 if input  = something then
do something with it
end sub
and so on


im not sure why your calling things modules because in many languages modules are different than sub routines but hey you can write it anyway you want. And yes I can follow along with yours just fine
Was This Post Helpful? 1
  • +
  • -

#3 Redxking  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 30-August 13

Re: Question does this Psuducode look righ?

Posted 30 August 2013 - 12:33 PM

Thank you for the reply. The reason why I call them modules is because the professor wants them to be called like that. He is extremely anal when it comes to formatting. There isn't any specific language in this class the class is meant to teach us how a program thinks but we do not run any type of language or code other then Psudocode.

As long what I have makes sense to you then I think I have done my job then.

I just want to ensure that if they enter a number value in they will get a output of a letter value, or a error if they value is less then 0 or greater then 100.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1