Beginning Programming Exercises
(expressed in "pseudocode")
1_1 Find the perimeter and area of a rectangle:
declare and initialize length and width variables;
set perimeter = 2 * (length + width);
set area = length * width;
output perimeter and area.
1_2 For a sales transaction, input price, compute taxes and net amount due,
then output the net amount due. Steps:
declare and initialize constants and variables;
input salesPrice;
set stateTax = 6.25% (0.0625) of sales price;
set cityTax = 2% of salesPrice; and
if salesPrice greater than $30,000
set luxuryTax = 10% of salesPrice;
set netAmount = salesPrice + totalTaxes;
output netAmount (with side label);
1_3 Compute pay for a salesperson according to the following rules:
Pay is to include base salary plus bonuses. A longevity bonus is paid
for service years: for whole years <= 5, $10 per year; for years > 5,
$20 per year. A sales commission bonus of 3% is paid for sales >= $5000
but less than 10000, or 6% for sales of $10000 or more. Input salary,
service years, and sales by that person. Output the pay amount.
declare and initialize constants and variables;
input base salary, service years, sales;
compute longevity and sales commission bonuses;
output pay;