Programming Expert Only

profilebsynclaire76
pc_part1.docx

Sequential Structures

Part 1

Pseudo code for a program that applies a discount on an item price

[1] Program: applyDiscount

[2] Create variable productPrice as double

[3] Create variable discount as double

[4] Create variable discountedPrice as double

[5] productPrice = get value from user input

[6] discount = get value from user input

[7] discountedPrice = productPrice * (1 – discount)

[8] Display discountedPrice

[9] End program

Pseudo code Description

Line 1: this is where the program is initialized.

Line 2: the variable productPrice is created and assigned the data type double (the double data type is used for floating point numbers or fractional numbers).

Line 3: another variable called discount is created and also assigned the data type double.

Line 4: the variable discountedPrice is also created and assigned the data type double.

Line 5: the productPrice variable is initialized and assigned a function get value which requests the user to enter the price of the product.

Line 6: the discount variable is also initialized and assigned the function get value which requests the user to enter the discount.

Line 7: the value stored in the discountedPrice variable is computed by subtracting the discount value from 1 and multiplying the result with the productPrice.

Line 8: the current value stored in the discountedPrice variable is displayed.

Line 9: the program is terminated.

Part 2

Pseudo code for a program that captures the credit card payment

[1] Program: captureCreditCardPayment

[2] Create variable accountNumber as integer

[3] Create variable expirationDate as string

[4] Create variable cvvCode as integer

[5] Create variable totalAmount

[6] Create variable payment as double

[7] totalAmount= get value from user input

[8] currentBalance= get value from credit card

[9] Payment = currentBalance – totalAmount

[10] Display payment

[11] Display accountNumber

[12] Display expirationDate

[13] Display cvvCode

[14] End program