Jump to content



Toggle shoutbox Shoutbox Open the Shoutbox in a popup

@  Elwood : (17 December 2018 - 11:12 AM) Hit me with an invite Blazer. Elwood288 #6474
@  Mage Girl : (17 December 2018 - 10:28 AM) Did I hear the word Discord?
@  Fire Blazer : (17 December 2018 - 01:07 AM) @Elwood you should join our Discord
@  Fire Blazer : (17 December 2018 - 01:07 AM) yo Mage Girl~ hi Elwood~
@  xcrash1998 : (15 December 2018 - 08:42 AM) It is always nice to have a chat
@  Elwood : (14 December 2018 - 08:21 PM) Hola amigos! I am still alive! Boy I miss this place being active.
@  Mage Girl : (13 December 2018 - 09:56 AM) A wild Mage Girl appears! Hi people who may or may not remember me lol
@  Fire Blazer : (08 December 2018 - 06:57 PM) but as they say a country is made of its people so IMO FES itself is still kind of alive so long as its people still talk a bit and remember the good times XD
@  Fire Blazer : (08 December 2018 - 06:56 PM) also yeah we're alive just not the forum really lol
@  Fire Blazer : (08 December 2018 - 06:56 PM) ...?
@  Rujio : (07 December 2018 - 07:03 AM) We're just mostly not actually here
@  kirant : (06 December 2018 - 08:41 PM) We're alive. I think.
@  Ezra : (06 December 2018 - 04:25 AM) It's been AGES since I logged in last, how's FES doing?
@  Ramiel : (04 December 2018 - 04:42 AM) Yo
@  acceptance : (03 December 2018 - 05:43 PM) truly
@  Fire Blazer : (02 December 2018 - 07:42 PM) i see
@  Mig64 : (28 November 2018 - 07:58 PM) I'M PRETTY SURE SOMEONE DID SAY CAPS LOCK
@  Fire Blazer : (28 November 2018 - 01:21 AM) DID SOMEONE SAY CAPS LOCK
@  acceptance : (25 November 2018 - 11:29 PM) MY CAPS LOCK IS ALSO FUNCTIONAL
@  Cero : (19 November 2018 - 09:52 AM) woah, been a bit since ive been on here

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