Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Pseudocode problem help.

pseudocode

  • Please log in to reply
2 replies to this topic

#1 mirror1

mirror1

    CC Lurker

  • New Member
  • Pip
  • 3 posts

Posted 22 February 2012 - 02:23 PM

I need help with my psudocode

Question is:
algorithm will keep track of a customer’s purchases at the local fireworks stand. Customers will not know exactly how many items they will purchase, so using a FOR loop on this lab is not allowed. Let’s keep the rules simple.
1) Accept the dollar value of each item purchased from the user until the user is finished.
2) When purchases are complete, enter a sentinel value of -1 (indicating the user has finished).
3) If more the item purchased is 50.00 or more, give your customer a 10% discount on their item purchased.
4) Display all of the purchases to the customer with the original price and the discount price

My code so far:

Begin FireWorkCalculation

Input "Enter price of item: "&price
WHILE (continue = Y)
Input continue Prompt "Do you wish to continue?"
WHILE (continue = N)
Display continue Prompt "You have completed your order."
ENDWHILE
If totalPrice <= 50.00 then (totalPrice*.10 = fullamount)

End

Any help will be appreciated and thanks in advance:)
  • 0

#2 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 22 February 2012 - 04:01 PM

A price of -1 would probably be a simpler loop condition.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#3 lespauled

lespauled

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1360 posts
  • Programming Language:C, C++, C#, JavaScript, PL/SQL, Delphi/Object Pascal, Visual Basic .NET, Pascal, Transact-SQL, Bash

Posted 23 February 2012 - 06:42 AM

you code says "If totalPrice is LESS THAN or equal to 50, not more.

Also, your while is AFTER the input, so it will never receive another value.
  • 0





Also tagged with one or more of these keywords: pseudocode

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download