• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

How The Heck Do I Write A Pseudocode?

applesseed

Senior member
Okay... I know I'm an @$$ for asking this assignment for my "Software Development" course (IT course requirement) but I personally never know how to do this kind of stuff. So I'm asking you for your kind help. I'm not asking you to do it for me because that's unfair but rather take a look at my own pseudocode attempt. Give me some feedbacks or guides. Of course if you'd like to write the p-code for me, I'd thankfully appreciated


Requirements:
The user enters the price of the item they want to purchase, the down payment they can afford, the best interest rate they could find, and the number of payments in months (12, 24, 48, 60). When the user clicks the monthly payment button, the program will return to them the amount of the loan and their monthly payments. When the user clicks the total button, the program will return the total they actually paid for their item.

Payment Algorithm:
The monthly payment on a loan may be calculated by the following formula:

Payment Forumula

Rate is the monthly interest rate, which is the annual interest rate divided by 12. N is the number of monthly payments, and L is the amount of the loan.



My attempt:

PROMPT user to enter the price of the item they want to purchase
PROMPT user the down payment they can afford
Prompt user the best interest rate they could find
Prompt user the number of payments in months (12, 24, 48, 60)



GET price of the item
STORE in a variable called L
IF user input is bad THEN
PROMPT user to re-enter price of the item
ELSE DISPLAY Thank you; Please proceed
END IF


GET down payment user can afford
IF user input is bad THEN
PROMPT user to re-enter down payment
ELSE DISPLAY Thank you; Please proceed
END IF


GET best interest user could find
STORE in a variable called R
IF user input is bad THEN
PROMPT user to re-enter best interest rate
ELSE DISPLAY Thank you; Please proceed
END IF


GET the number of payments in months
STORE in a variable called N
IF user input = 12
ELSE IF user input = 24
ELSE IF user input = 48
ELSE IF user input = 60
ELSE incorrect input THEN
PROMPT user to re-enter number of payments in months
END



PROMPT user to click monthly payment button
CALCULATE R multiplied by (1+R) raised to the power of N
divided by (1+R) raised to the power of N minus 1
multiply result by L
DISPLAY amount of loan and monthly payments
END




PROMPT user to click the total button
CALCULATE amount of loan
yadda yadda yadda yadda yadda yadda I don't understand
 
Doesn't look too bad, to me at least. The pseudocode I've written for Data Structures was more abstract but I suppose it depends on what the instructor is looking for.
 
when i write psuedo code...i have it less wordy....and more in code shape....

not really completely functional code.....but enough to bring the idea across!
 
I think its like

GET price of the item
STORE in a variable called L
IF user input is bad THEN
PROMPT user to re-enter price of the item
ELSE DISPLAY Thank you; Please proceed
END IF

would be translated into

GET (Item)
STORE (L)
IF (input = bad) THEN
PROMPT (re-enter price of Item)
ELSE DISPLAY (Thank you; Please proceed)
End it

I think thats how I did it, but I really think it depends on what your normal code would look like, AKA what language are you writing in.
 
Originally posted by: Schmitty
I think thats how I did it, but I really think it depends on what your normal code would look like, AKA what language are you writing in.
Pseudocode in general is not language specific.
 
If I were grading, I'd accept that as pseudocode. It can vary in the spectrum of english sentence fragments to almost code. I tend more to the almost code area. I find it to be more concise and makes for an easier transition to actual code.
 
Originally posted by: ActuaryTm
Originally posted by: Schmitty
I think thats how I did it, but I really think it depends on what your normal code would look like, AKA what language are you writing in.
Pseudocode in general is not language specific.

Your right but I think that it has to somewhat take a shape of the language your writing in. like there might not be an IF statement in some languages. it would dictate how your prof wanted to see it!
 
Basically, write code that ignores syntax errors and uses things like "get user input" where you can't remember what function reads from the console.
 
Thanks for the input guys... I'm still bump whether it is acceptable to the instructor. Hey... I'll give you a GMail account only if you seriously write the p-code for me. heh heh
 
Originally posted by: Schmitty
Originally posted by: ActuaryTm
Originally posted by: Schmitty
I think thats how I did it, but I really think it depends on what your normal code would look like, AKA what language are you writing in.
Pseudocode in general is not language specific.

Your right but I think that it has to somewhat take a shape of the language your writing in. like there might not be an IF statement in some languages. it would dictate how your prof wanted to see it!

What language could possibly not have an IF? I'd think a conditional branch is alway necessary.
 
Originally posted by: Schmitty

I think thats how I did it, but I really think it depends on what your normal code would look like, AKA what language are you writing in.

by next week i've got to choose a language like c++ to write, but as of now, I think my instructor wants to know how I can write the code that's easy to understand.
 
Psuedo code is simply a road map for writing actual code.

It's a way of thinking about what you have to do before you actually start writing the code... so when you get to that, you don't have to think about what to do next, only about coding it.

So writing psuedo code should be whatever makes it easier for you when coding.
 
could somebody show me how you would write the p-code for the two calculation? I just want to compare and contrast what other people would write.
 
I re-did my p-code - can someone give me feedback? I'm turning in at midnite Pacific time. If it's not readable to you, try clicking on the pics below. Thanks in advance.


MAINLINE
START
DEFINE number data in input area
USER-INPUT
Price_Of_Item
Down_Payment
Rate // user input divided by 12
N // user input 12, 24, 48, or 60 mo.
DEFINE number data in output area
PRINT-OUT
Loan_Amount
Monthly_Payment
Total_Actual_Paid
DEFINE number data in work area
DONE = ?NO?
DO READ routine
IF DONE = ?NO? THEN
DO PROCESS-INPUT routine UNTIL DONE = ?YES?
DO PRINT-OUT routine UNTIL DONE = ?YES?
ENDDO
ELSE DO ERROR routine
ENDIF
STOP



READ // read user input and set variables
READ price of item from user input
SET input to Price_Of_Item
READ downpayment price from user input
SET input to Down_Payment
READ annual interest rate from user input divided by 12
SET input to Rate
READ payments in months of 12, 24, 48, or 60 from user input
SET input to N
IF EOF THEN
MOVE ?YES? to DONE
ENDIF
ENDREAD



ERROR // determine if an error occurred
MOVE ?Incorrect data? to output area
WRITE a line
ENDERROR



PROCESS-INPUT // do calculation
COMPUTE amount of loan as Price_Of_Item minus Down_Payment
SET input to L
COMPUTE monthly payments as Rate multiplied by 1 plus Rate raised to the
power of N divided by 1 plus Rate raised to the power of N minus 1 multiply L
SET input to Monthly_Payment
COMPUTE total actual paid as Monthly_Payment multiply by N
SET input to Total_Actual_Paid
ENDPROCESS-INPUT



PRINT-OUT // display user?s request
IF user wants monthly payment THEN
DISPLAY amount of the loan from L and their monthly payment from Monthly_Payment
ELSE
DISPLAY total actually paid from Total_Actual_Paid
ENDIF
ENDPRINT-OUT


MAINLINE_Page_1.jpg
MAINLINE_Page_2.jpg
 
Originally posted by: Pepsi90919
pseudocode is like writing BASIC.

haha, I took a programming class a year or two ago. I loved writing pseudocode...because you can practically put it in the qbasic interpreter/compiler and it actually runs lol. BASIC is so close that it's sometimes easier to write BASIC than try to use pseudocode to explain in the shortest possible way what you're doing.
 
Back
Top