Assignment D

For each problem:

Problem D1

You will need to include the iomanip library, as well as the iostream library, for this problem.

Use three named constants for the following:
small beads with a price of 9.20 dollars per box
medium beads with a price of 8.52 dollars per box
large beads with a price of 7.98 dollars per box

Ask the user how many boxes of small beads, how many boxes of medium beads, and how many large beads they need.

Print the order in the following format:

SIZE          BOXES         COST PER BOX  TOTALS
Small             n                 x.xx   xx.xx
Medium            n                 x.xx   xx.xx
Large             n                 x.xx   xx.xx
TOTAL                                     xxx.xx

Replace the n x.xx xx.xx and xxx.xx with the data printed from the constants and variables in your program.
Align everything exactly as shown in the example by specifying the field width, precision, and left or right.

Test the program user input of 9 boxes of small beads, 8 boxes of medium beads, and 7 boxes of large beads.
Be sure everything aligns exactly like the format specified.

Problem D2

You will need to include the iomanip library, as well as the iostream library, for this problem.

In classical physics:
momentum is mass times velocity ( m * v )
kinetic energy is one half the mass times the square of the velocity ( m * v2 / 2 )

Prompts the user for the mass and the velocity as input.
Use double variables.
Then compute the momentum and kinetic energy.
Print the momentum and the kinetic energy with identifying text.
The execution result should have six lines 1) input mass, 2) input velocity, 3) output mass, 4) output velocity, 5) momentum, 6) kinetic energy.
Round the printed values to two decimal positions and align the decimal points.

Test data, run the program twice:
First test input 5.0 kilograms and 4.0 meters per second
Second test input 3.15 kilograms and 10.0 meters per second

Problem D3

Prompt the user to type a first and last name, separated by one space.
Use getline to read all the characters input by the user, and save these characters in a string variable.
Print the line you read.

Test the program twice:
First with the name: George Washington
then with the name: Franklin Delano Roosevelt