FSU COP 3014 - PROGRAM Rainbow Height Calculator

Unformatted text preview:

PROGRAM Rainbow Height Calculator AUTHOR FSU MAIL NAME RECITATION SECTION NUMBER RECITATION INSTRUCTOR NAME COP 3014 Spring 2013 PROJECT NUMBER 1 DUE DATE PLATFORM Windows OS Microsoft Visual C Express 2010 IDE SUMMARY The height of a rainbow can be calculated using very simple formulas Because of the way light is refracted by water droplets the angle between the level of your eye and the top of a rainbow is always the same If you know the distance to the rainbow you can multiply it by the tangent of that angle to find the height of the rainbow The magic angle is 42 333333 degrees C works in radians however so you have to convert the angle to radians with this formula radians degrees PI 180 where PI is 3 141592 The tangent of the angle can then be calculated using the tan function in the C standard library cmath If you multiply the tangent by the distance to the rainbow you get the height of the rainbow You can sometimes see a second fainter rainbow outside a bright rainbow This second rainbow has a magic angle of 52 25 degrees This program asks the user for the distance to the main rainbow and then prints the distance to the main rainbow the height of the main rainbow and the height of the secondary rainbow INPUT OUTPUT The user interactively inputs the distance to the rainbow as an integer in meters The input distance value is printed Then the height of the main rainbow and the height of the secondary rainbow are printed Real numbers are output with three digits of precision ASSUMPTIONS Distance and height units are in meters When asked for a distance value the user types in a valid whole number Error checking does not need to be done on this input value HEADER FILES include iostream standard IO routines include iomanip for output formatting include cmath standard math functions using namespace standard standard C namespace MAIN FUNCTION int main named constants const double PI 3 141592 mathematical constant const double MAGIC ANGLE 1 42 333333 angle between level of your eye and top of the main rainbow in degrees const double MAGIC ANGLE 2 52 25 angle for 2nd rainbow const double CONVERT FACTOR 180 0 for conversion to radians int distanceToRainbow distance to rainbow as a whole number double height1 height of main rainbow as calculated by program radians1 magic angle for main rainbow in radians tangent1 tangent of the main magic angle height2 height of 2nd rainbow as calculated by program radians2 magic angle for 2nd rainbow in radians tangent2 tangent of the 2nd magic angle print an introductory output heading cout endl endl cout Welcome to the Rainbow Height Calculator endl endl cout You will be asked to enter the distance to endl cout a main rainbow as a whole number in meters endl cout Then this program will show you the height of endl cout the main rainbow and the secondary rainbow endl endl cout endl endl set up real number output formatting cout fixed showpoint setprecision 3 read in the distance and echoprint cout Please enter the distance to the rainbow cin distanceToRainbow cout endl Distance to main rainbow in meters as input distanceToRainbow endl calculate the main rainbow s height radians1 MAGIC ANGLE 1 PI CONVERT FACTOR tangent1 tan radians1 height1 tangent1 static cast double distanceToRainbow calculate the secondary rainbow s height radians2 MAGIC ANGLE 2 PI CONVERT FACTOR tangent2 tan radians2 height2 tangent2 static cast double distanceToRainbow output the results cout Height of the main rainbow in meters height1 endl cout Height of the secondary rainbow in meters height2 endl print a closing message and exit program cout endl Execution Terminated endl endl cout endl end return 0 E N D O F P R O G R A M PROGRAM Rainbow Height Calculator AUTHOR FSU MAIL NAME RECITATION SECTION NUMBER RECITATION INSTRUCTOR NAME COP 3014 Spring 2013 PROJECT NUMBER 2 DUE DATE PLATFORM Windows OS Microsoft Visual C Express 2010 IDE include iostream used for basic input output in c include string for use of the toupper function include iomanip for use of the fixed and setprecision functions include cmath for use of the ceil floor function using namespace std int main initialized variables to zero int bookID 0 instockBooks 0 float bookPrice 0 orderCost 0 profit 0 booksNeeded 0 enrollment 0 bookCost 0 initialize variables to null char bookRequirment NULL bookCondition NULL introductory prompt cout n n WELCOME TO THE BOOKSTORE ORDER ESTIMATION PROGRAM n n n ask users for input cout Enter the book ID number ex 2134 cin bookID cout Enter the books price per copy cin bookPrice cout Enter the current number of books in stock cin instockBooks cout Enter the expected class size enrollment cin enrollment cout Specify if the book is required R or suggested S cin bookRequirment cout Enter N if the book is NEW or enter O id the book is USED OLD cin bookCondition bookRequirment toupper bookRequirment ensures uppercase input by user bookCondition toupper bookCondition ensures uppercase input by user check conditional values and determine what the bookstore needs if bookRequirment R bookCondition N enrollment 90 else if bookRequirment R bookCondition O enrollment 65 else if bookRequirment S bookCondition N enrollment 40 else if bookRequirment S bookCondition O enrollment 20 do the calculations booksNeeded enrollment instockBooks booksNeeded ceil booksNeeded Needed to raise bookNeeded to next whole number orderCost booksNeeded bookPrice profit orderCost 20 profit profit 80 output the report for bookstore order and profits if any cout n n BOOK ORDER ESTIMATION SUMMARY n Number Of Books To Order booksNeeded endl if no books need to be ordered order cost and profit will not be shown if booksNeeded 0 cout Total Cost of this Order fixed setprecision 2 orderCost endl cout Expected Profit On Books Ordered fixed setprecision 2 profit endl AUTHOR FSU MAIL NAME RECITATION SECTION NUMBER RECITATION INSTRUCTOR NAME COP 3014 Spring 2013 PROJECT NUMBER 3 DUE DATE PLATFORM Windows OS Microsoft Visual C Express 2010 IDE SUMMARY The number of ants will be read from the file the band stomps the ants 10 000 at a time for the first 5 minutes then 5 000 at a time for the remaining time The professor s pray will kill 50 000 ants only if they reach the 50 yard line then the spray will diminish INPUT The data will be input from the text file provided OUTPUT an intro to each simulation with the stats of the ants will be displayed initially The time ants left yards consumed by ants and the progress of the band and spray


View Full Document

FSU COP 3014 - PROGRAM Rainbow Height Calculator

Download PROGRAM Rainbow Height Calculator
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view PROGRAM Rainbow Height Calculator and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view PROGRAM Rainbow Height Calculator 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?