Assignment D

Use the lab instructions given on the Internet at http://voyager.deanza.edu/~oldham
Use the same format for the opening comments as in assignment A, with your name, course and quarter, assignment, problem, and short problem description.
Type a program, as described in the following description. Compile it, correct any errors and execute it.
Copy the execution results into an   /* Execution Results:   comment.
Print the completed program with the execution results from within the Interactive Development Environment.
Always use memory constants when constant values are needed, except numbers such as 0 or 1 which can be used in the code where their use is clear.

Chapter 3 Problem 28

Hint: Use a cast.
Test data, run the program twice:
First test input 3.14159   The result should be 3
Second test input 39.82   The result should be 9

Chapter 3 Problem 32

Use memory constants; do not use #define; do not put numbers down in the code.
The execution result should have three lines 1) Input, 2) Centigrade, 3) Fahrenheit.
Round the printed values to one decimal position and align the decimal points.
Test data, run the program three times:
First test input 37.1 degrees centigrade
Second test input -40 degrees centigrade
Third test input 0 degrees centigrade

Problem D1

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 )

Write a program that prompts the user for the mass and the velocity as input.
Use double variables.
The program then computes the momentum and kinetic energy.
Finally, the program prints 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 one decimal position 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.1 kilograms and 10.0 meters per second