5 Replies - 1551 Views - Last Post: 12 January 2014 - 08:47 PM Rate Topic: -----

#1 Laterali  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 07-January 14

Need Help with Syntax in Pseudocode

Posted 07 January 2014 - 06:18 PM

I've got a project I've been working on, and am just looking for some feedback on how it looks. I'm not looking for anyone to do it for me, just for some advice on whether or not I'm in the ballpark for it being formatted properly.

Basically it's a project where I'm supposed to write a currency conversion program in pseudocode, but I have to make sure the syntax is correct and I'm using the right variables. Normally we do study groups and bounce ideas off each other, but not this time.

I'd actually prefer we were using an actual language, then at least I could test it for myself to see if it worked.

Main Module
	Declare CurrencyType as Integer
	Declare IntValue as Real
	Declare USValue as Real
	Declare Continue as String
	Do
		Display “Would you like to convert a currency? Y or N”
		 Input Continue
		If continue = y Then
			Call Display Menu Module
			Call International Value Module
			Call Convert Currency Module
			Call Display Results Module
		Else
			Display “Goodbye.”
		While continue = y 
End Main Module
Perform Display Menu Module
	Declare CurrencyType as integer
	Display “Welcome to the Currency Converter Program.”
	Display “Please Select the currency you would like to convert.”
	Display “Select 1 for Canadian Dollars.”
	Display “Select 2 for Mexican Pesos.”
	Display “Select 3 for British Pounds.”
	Display “Select 4 for Japanese Yen.”
	Display “Select 5 for E.U. Euros.”
	Input CurrencyType
	If CurrencyType (0 < CurrencyType < 6) Then
		Continue
	Else
		Display “Error 4: Invalid Menu Selection.”
	End If
End Display Menu Module

Perform International Value Module
	Declare IntValue as integer
	Display “Please enter the value of the currency you would like to convert.”
	Input IntValue
	If IntValue ( 0>IntValue) Then
		Display “Error 1: Invalid Input”
	Else 
		Continue 
	End If
	If IntValue ( 0 < IntValue < 1,000,000) Then
		Display “Please Enter a valid value.”
	End If
End International Value Module

Perform Convert Currency Module
	Declare Rate as Real
	Declare USValue as Real
	Rate = 0
	If CurrencyType = 1
		Then Rate = 1.4680
		If CurrencyType = 2
			Then Rate = 9.5085
			If CurrencyType = 3
				Then Rate = .6085
				If CurrencyType = 4
					Then Rate = 104.9200
					If CurrencyType = 5
						Then rate = .7676
	End If
	USValue = Rate * IntValue
End Convert Currency Module

Perform Display Results Module

Declare Nation as String
Declare Currency as String
If CurrencyType = 1 then
	Nation = Canada
	Currency = Dollars
	If CurrencyType = 2 then
		Nation = Mexico
		Currency = Pesos
			If CurrencyType = 3 then
				Nation = England
				Currency = Pounds
					If CurrencyType = 4 then
						Nation = Japan
						Currency = Yen
							If CurrencyType = 5 then
								Nation = Euro
								Currency = Euro
	End If
	Display “ “IntValue” “Currency” from “Nation” is equal to “USValue”.”


Is This A Good Question/Topic? 0
  • +

Replies To: Need Help with Syntax in Pseudocode

#2 ForteGS  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 21
  • Joined: 06-January 14

Re: Need Help with Syntax in Pseudocode

Posted 08 January 2014 - 12:39 AM

I'd say avoid using magic number.
Was This Post Helpful? 1
  • +
  • -

#3 Laterali  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 07-January 14

Re: Need Help with Syntax in Pseudocode

Posted 08 January 2014 - 02:37 PM

Unfortunately the numbers representing the countries I have to leave in, as they are a part of the project given by the instructor.

He also gave me the ridiculous equation of US Value= rate * Int Value. The whole point of the program is supposed to take foreign currency and convert it to USD, but that equation doesn't convert foreign currency to USD, it does the complete opposite, but I have to leave it in, since it's not a real program anyways.
Was This Post Helpful? 0
  • +
  • -

#4 ForteGS  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 21
  • Joined: 06-January 14

Re: Need Help with Syntax in Pseudocode

Posted 08 January 2014 - 09:24 PM

Well, as long as you remember the good principles in programming. It does not matter. Fulfill the your instructor's requirements.
Was This Post Helpful? 0
  • +
  • -

#5 Lemur  Icon User is offline

  • Pragmatism over Dogma
  • member icon


Reputation: 1383
  • View blog
  • Posts: 3,514
  • Joined: 28-November 09

Re: Need Help with Syntax in Pseudocode

Posted 12 January 2014 - 02:04 PM

Then you're missing the point of psuedo code. Knowing if it works syntactically is irrelevant.

The point of psuedo code is to diagram the flow of a program, such that it can easily be translated into any language. It needs to be agnostic and as close to plain english as possible. The programming language that comes closest to this naturally is Ruby.

Do not try and write a program in psuedo code, only an idea and method of how to write the actual program. Underestimate its value at your own peril. It's one of the most useful tools as a Software Engineer to be able to quickly draw out psuedocode on a whiteboard to show their ideas.
Was This Post Helpful? 0
  • +
  • -

#6 Laterali  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 07-January 14

Re: Need Help with Syntax in Pseudocode

Posted 12 January 2014 - 08:47 PM

View PostLemur, on 12 January 2014 - 02:04 PM, said:

Then you're missing the point of psuedo code. Knowing if it works syntactically is irrelevant.

The point of psuedo code is to diagram the flow of a program, such that it can easily be translated into any language. It needs to be agnostic and as close to plain english as possible. The programming language that comes closest to this naturally is Ruby.

Do not try and write a program in psuedo code, only an idea and method of how to write the actual program. Underestimate its value at your own peril. It's one of the most useful tools as a Software Engineer to be able to quickly draw out psuedocode on a whiteboard to show their ideas.


I agree with you, unfortunately my instructor doesn't. His idea of pseudo code is some mish mash version of pseudo code and a real language. I did poorly the first 6 weeks because I was writing pseudo code the way pseudo code should be written, but he adds all the rules a coding language would have onto pseudo code, like all the variables, syntax, and the like. I'd love to write in pseudo code, or any language, he's got us using this weird hybrid.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1