Jump to content



Toggle shoutbox Shoutbox Open the Shoutbox in a popup

@  Fire Blazer : (25 March 2019 - 10:43 PM) how things have changed
@  Elwood : (12 March 2019 - 08:31 AM) (a sigh somewhere between small and large)
@  kirant : (12 March 2019 - 05:40 AM) (larger sigh)
@  Fire Blazer : (11 March 2019 - 08:49 PM) (small sigh)
@  Fire Blazer : (25 February 2019 - 05:07 AM)
@  Fire Blazer : (06 February 2019 - 04:34 AM) Cardfight Vanguard X? huh
@  Mercurius : (05 February 2019 - 10:49 PM) THE ONE SWITCH GAME I WANTED TO HAPPEN THE SECOND I LEARNED IT WAS REGION FREE PRE-RELEASE OMFG 2019 IS GIVING ME EVERY SINGLE REASON TO HAVE BOUGHT IT WOULD PAY ONLINE FOR 10/10
@  Fire Blazer : (03 February 2019 - 10:08 PM) plz no tumblrweed lol
@  acceptance : (02 February 2019 - 06:08 PM) (Like a tumbleweed, but more opinionated)
@  acceptance : (02 February 2019 - 06:08 PM) *Tumblrweed*
@  kirant : (02 February 2019 - 05:44 PM) *Tumbleweed*
@  Elwood : (02 February 2019 - 05:35 PM) *Tumbleweed*
@  Fire Blazer : (31 January 2019 - 12:11 AM) (silence)
@  Fire Blazer : (12 January 2019 - 08:55 PM) tho personally I guess I'm not too afraid of responding to old messages anyway sometimes, haha
@  Fire Blazer : (12 January 2019 - 08:54 PM) to have discussions where people respond at their own convenience
@  Fire Blazer : (12 January 2019 - 08:54 PM) forums could still be used but we'd have to make a bit of an effort I guess
@  Fire Blazer : (12 January 2019 - 08:54 PM) I agree with Mage Girl/Cero/Elwood/Kirant lolol
@  xcrash1998 : (12 January 2019 - 10:15 AM) And yeah missing stuff on discord is easy depending on when most people are online
@  xcrash1998 : (12 January 2019 - 10:11 AM) I think there are just fewer people interested in taking part on forums since most information is already accesible trough the many means.
@  Mercurius : (09 January 2019 - 02:46 AM) Well, at the same time I also don't frequent most of the discord channels I'm a part of, though.

Photo

Some real basic questions - PseudoCode


  • Please log in to reply
No replies to this topic

#1 MagixTricks

MagixTricks

    Member

  • Members
  • PipPipPip
  • 36 posts

Posted 20 September 2013 - 12:39 PM

Okay so i'm Taking a course on programming, and we're starting with pseudocode. Unfortunately the teacher does not like to- well, teach, so I'm doing it on my own. I got it pretty decent, and I can do the assignment just fine how it is "expected to be done"
but I wanted to try and go further.

Here is the assignment:
QUOTE
A customer in a storage is purchasing five items.  Design a program that asks for the price of each item, and then displays the subtotal of the sale, the amount of sales tax, and the total.  Assume the sales tax is 6%."


Okay so before i show my pseudocode; I understand that it would be simple to just have the user input all the item prices, and then do the calculations.

What i am trying to achieve with my pseudocode is to have the computer display current sub totals and current amount of tax being paid after each item. These prices would obviously build up as you go from item price 1 to item price 2 to item price 3, etc...

Here's the pseudocode:
CODE
//Declarations
Declare INT itm_1
Declare INT itm_2
Declare INT itm_3
Declare INT itm_4
Declare INT itm_5
Declare VAR crnt_Sub
Declare VAR crnt_Tax
Declare VAR total

//BEGIN CODE
 //Display Box [Item1]
  Display "Please Enter the price of your first item"
 //Input/Output
  Input itm_1
  crnt_Sub = itm_1  
  Calc crnt_Tax = itm_1 * .06
 //Display Box
  Display "Your current sub total is: $", crnt_Sub
  Display "Your current tax is: $", crnt_Tax
 //
 //Display Box [Item2]
   Display "Please Enter the price of your next item"
 //Input/Output
  Input itm_2
  crnt_Sub = crnt_Sub + itm_2  
  Calc crnt_Tax = crnt_Tax + (itm_2 * .6)
 //Display Box
  Display "Your current sub total is: $", crnt_Sub
  Display "Your current tax is: $", crnt_Tax
 //
 //Display Box [Item3]
  Display "Please Enter the price of your next item"
 //Input/Output
  Input itm_3
  crnt_Sub = crnt_Sub + itm_3  
  Calc crnt_Tax = crnt_Tax + (itm_3 * .6)
 //Display Box
  Display "Your current sub total is: $", crnt_Sub
  Display "Your current tax is: $", crnt_Tax
 //
 //Display Box [Item4]
  Display "Please Enter the price of your next item"
 //Input/Output
  Input itm_4
  crnt_Sub = crnt_Sub + itm_4  
  Calc crnt_Tax = crnt_Tax + (itm_4 * .6)
 //Display Box
  Display "Your current sub total is: $", crnt_Sub
  Display "Your current tax is: $", crnt_Tax
 //
 //Display Box [Item5]
  Display "Please Enter the price of your next item"
 //Input/Output
  Input itm_5
  crnt_Sub = crnt_Sub + itm_5  
  Calc crnt_Tax = crnt_Tax + (itm_5 * .6)
 //Display Box
  Display "Your current sub total is: $", crnt_Sub
  Display "Your current tax is: $", crnt_Tax
 //
 //
 //Decision Box
 Display "Are you ready for your total?"
  //If - Yes
   Display "Your Total is: $", total
   total = crnt_Sub + crnt_Tax
 //Connect To END CODE
  //If - No
   Display "Would you like to go back to change a price?"
    //If - Yes
     Display "Which price would you like to change?"
      //If - 1
       ******CONNECT BACK TO itm_1 Input Code
      //If - 2
       ******CONNECT BACK TO itm_2 Input Code
      //If - 3
       ******CONNECT BACK TO itm_3 Input Code
      //If - 4
       ******CONNECT BACK TO itm_4 Input Code
      //If - 5
       ******CONNECT BACK TO itm_5 Input Code
      //If - None
       ******CONNECT BACK TO "Are you ready for your total?"
    //If - No
     ******CONNECT BACK TO "Are you ready for your total?"
     
//END Code


See now what I'm not entirely sure of- is how exactly legal what i'm doing is. Don't look at the Y/N stuff, since I'm probably not gonna add that in the final pseudocde, but what I would liek help with is :
CODE
crnt_Sub = crnt_Sub + itm_5  
  Calc crnt_Tax = crnt_Tax + (itm_5 * .6)

And all of the ones that are thee same thing just using different variables before it.
Basically, I'm not sure if it would be legal to have a variable equal itself plus other numbers?

If it isn't, would I have to add my declarations? I doubt it would be 5 more declarations so it is specific to the program, because what if we wanted to have more than 5 items? I kind of want to base it off the latter. So basically, I'm just not sure how I would go about making one variable equal it's already previously set self + an additional amount.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users