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.