Goals: Developing problem-solving skills, declaring variables, multi-way branches, data validation.
Problem: Complete Programming Challenge 4.19 in your text book. Do not accept values larger than 10 meters or smaller than 1 x 10-20 meters as input for the wavelength (check with a “simple” or “single-branched” if and ask the user to re-enter if his/her input if it is out of range. In addition to category of the wave also output the frequency and energy of the wave given the formula
λν = c
where λ is the wavelength (m), ν is the frequency, and c is the speed of light in a vacuum (3 x 108 m/sec) and the formula
E = hν
where E is the energy (J), h is Plank’s constant (6.626 x 10-34 J s), and ν is the frequency (s-1).
Note to enter values in scientific notation list the value followed by e and the power of 10. For example you could declare a constant for the value of Plank’s constant with the C++ statement
const double Plank = 6.626e-034;

 

 

 



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *