Jump to content



Toggle shoutbox Shoutbox Open the Shoutbox in a popup

@  Oblivion Knight : (26 February 2024 - 11:30 AM) Whoa I can edit a typo. The technology.
@  Oblivion Knight : (26 February 2024 - 11:29 AM) Obligatory message.
@  Elwood : (02 January 2024 - 04:19 AM) Happy New Year!!!
@  Aaron : (13 February 2023 - 09:19 PM) I'm still out here alive. If you remember me, I hope you're doing well!
@  Aaron : (13 February 2023 - 09:09 PM) 2023 and this place is still up huhh
@  Elwood : (05 January 2023 - 07:58 AM) Ah a Christmas greeting from Wolfie! Even if I saw it way late Merry Christmas and Happy New Year to everybody!
@  Cero : (31 December 2022 - 09:27 PM) Man that bot went crazy
@  Whitewolf8 : (24 December 2022 - 10:02 AM) I return once more on the eve of Christmas to haunt you all again!... Mainly Elwood. Hello!
@  Elwood : (25 November 2022 - 04:58 AM) A bot! Ah the nostalgia!
@  Elwood : (02 November 2022 - 02:30 PM) Yo ho ho ho! Thar be the white wolf!
@  Whitewolf8 : (24 October 2022 - 12:29 AM) Well, blimey it's been a while. Hoy there! If anyone's still alive here anyway.
@  Valke : (21 April 2022 - 12:12 PM) im taking the 2nd shout of 2022 😂
@  Elwood : (03 March 2022 - 10:12 PM) Mwuhahaha! The first shout of 2022 is mine!
@  Fire Blazer : (12 November 2021 - 05:22 PM) *also stretches arms a little*
@  xcrash1998 : (07 November 2021 - 08:42 PM) "streches arms"
@  Ezra : (07 May 2021 - 05:20 AM) Maybe I'll pop on the discord soon
@  Fire Blazer : (01 April 2021 - 08:08 PM) Aaaaaaand done~ :P
@  xcrash1998 : (29 March 2021 - 08:52 AM) I guess we are one more post away from counting to 2500
@  Fire Blazer : (10 March 2021 - 11:39 PM) but I have bad memory and can't remember ;(
@  Elwood : (15 February 2021 - 10:23 AM) I'd like to but I've told you about my issues with discord before.

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.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users