2 - Chapter 2 - Introduction To C++
2 - Chapter 2 - Introduction To C++
1. Convert the following pseudocode to C++ code. Be sure to define the appropriate
variables
a. Store 20 in the speed variable.
Store 10 in the time variable.
Multiply speed by time and store the result in the distance variable.
Display the contents of the distance variable.
3. Annual Pay
Suppose an employee gets paid every two weeks and earns $2,200 each pay period. In a year the
employee gets paid 26 times. Write a program that defines the following variables:
payAmount This variable will hold the amount of pay the employee earns each pay period.
Initialize the variable with 2200.0.
payPeriods This variable will hold the number of pay periods in a year. Initialize the variable
with 26.
annualPay This variable will hold the employee’s total annual pay, which will be calculated.
The program should calculate the employee’s total annual pay by multiplying the employee’s pay amount
by the number of pay periods in a year and store the result in the annualPay variable. Display the total
annual pay on the screen.
4. Stock Commission
Kathryn bought 750 shares of stock at a price of $35.00 per share. She must pay her stockbroker a 2
percent commission for the transaction. Write a program that calculates and displays the following:
• The amount paid for the stock alone (without the commission)
• The amount of the commission
• The total amount paid (for the stock plus the commission)
• The approximate number of customers in the survey who purchase one or more energy drinks
per week
• The approximate number of customers in the survey who prefer citrus-flavored energy drinks