Question

Write a program to print five tables (5) displaying the range that a ball would travel...

Write a program to print five tables (5) displaying the range that a ball would travel when it is thrown with an initial velocity v0 and angle θ.

One table should be calculated for each of the initial velocities: 0, 1, 10, 100, and 1000 meters per second.

The table should have one row for e very 5 degrees for angles between 5 and 85 degrees inclusive.

Note that this assignment does not require a READ statement since all data required can be constructed into the program.

Nested DO loops are required to solve this problem. Do not unnecessarily duplicate code.

Columns should have appropriate headings.

White space should separate the tables.

Do not use formatted Output for the program.

implicit none

! Declare constants
REAL, PARAMETER :: gravity = 9.81, pi=3.14159

! Declare variables
REAL :: velocity_initial
REAL :: range, alpha
INTEGER :: angle

! Display initial header
   WRITE (*,*)
   WRITE (*,*) "displaying the range that a ball would travel"
   WRITE (*,*)

! Initialize variables
velocity_initial = 0, 1, 10, 100 ,1000

! loop over all specified angles

loop: do angle = 5, 85, 5

! Covert angle(degree) to to radians
  
   alpha = angle * pi / 180.0

! Calculate range of a ball would travel

   range = (-2. * velocity_initial**2 / gravity) * cos(alpha) * sin(alpha)

! Write the range for this angle
   WRITE (*,*) 'Angle = ', angle, ' degree; Range = ', range, &
' meters'


END DO loop

END program ballistic

fortran

I shoul display result by initial velocity 0 1 100 1000

but I am not sure how to display all of them

i can only do for one value

i think i should use loop..

Comment

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code program ball ! constant real values > gravitation, pi val ! real values> angles, myalpha implicit none ! Declaring the c!Display a warning WRITE (*, *) Error, angle range invalid CYCLE !end of If END IEF !Comparing range to previous max range.Angle Angle = Angle Angle- Angle Angle Angle Angle Angle Angle Angle = 35 degree; Range= -0.00000000E+00 meters 40 degree; RaTABLE 3 Angle Angle 5 degree; Range1.77011251 10 degree; Range# -3.48644137 15 degree; Range# -5.09683657 20 degree; Range -6Angle- Angle- Angle Angle Angle Angle Angle 55 degree; Range957.893005 60 degree; Range882.799316 65 degree; Range= -780.8823Executable Code

program ball

! constant real values > gravitation, pi_val

! real values > angles, myalpha

implicit none

! Declaring the constant real values

REAL, PARAMETER :: gravitation = 9.81, pi_val=3.14159

! variable declarations

REAL :: velocities(5)

REAL :: myrange, myalpha

INTEGER :: angles, i

REAL :: maxdeg, maxrange

! variable Initialization

maxdeg = 5.

maxrange = 0

velocities = (/0, 1, 10, 100, 1000/)

! Displaying result

WRITE (*,*)

    WRITE (*,*) "Displaying the range of the ball will travel"

    WRITE (*,*)

! looping over all the given initial_velocities

loop1: do i=1,5

    WRITE (*,*)

    WRITE (*,*) "TABLE",i

    WRITE (*,*)

! looping over all the given initial_angles

loop: do angles = 5, 85, 5

! Coverting angles in degree to the radian values

myalpha = angles * pi_val / 180.0

! Calculating the range of the ball

myrange = (-2. * velocities(i)**2 / gravitation) * cos(myalpha) * sin(myalpha)

! Writing the range for angles

    WRITE (*,*) 'Angle = ', angles, ' degree; Range = ', myrange, &

     ' meters'

! check the angles range between 0 and 85

     ! if loop

    IF ( angles < 0 .or. angles > 85 ) then

          !Display a warning

          WRITE (*,*) "Error, angle range invalid"

CYCLE

     ! end of If

    END IF

! Comparing range to previous max range. If the range is large

! saving it and angle's occurance.

     ! if loop

     IF ( myrange > maxrange ) THEN

     maxrange = myrange

     maxdeg = angles

     ! end of If

     END IF

! end of Do

END DO loop

! Skiping a line

! printing out max range and angle of occurrance.

WRITE (*,*) ' '

WRITE (*,*) 'Maximum range = ', maxrange, ' at ', maxdeg, 'degrees'

END DO loop1

end program ball

Add a comment
Know the answer?
Add Answer to:
Write a program to print five tables (5) displaying the range that a ball would travel...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Python. Write a program that will calculate the amount of money a person would earn...

    In Python. Write a program that will calculate the amount of money a person would earn over a period of time if his/her salary is one penny the first day and two pennies for the second day, and continue to double each day. Hints: Declare variables Get the number of days from the user. Show the salary table for each day 4. Use ‘for loop’ to loop through the range of days (1, num_days +1) 5. Display the total pay...

  • Write the pseudocode below as a working Python program. Take a screenshot of your code and...

    Write the pseudocode below as a working Python program. Take a screenshot of your code and output and paste into your answer document. User input of ‘y’ or ‘Y’ should cause the loop to continue.    // Constant for the commission rate    // Declare as a global variable    Constant Real COMMISSION_RATE = 0.10     Module main()        // Local variable         Declare String keepGoing = "y"         // Calculate as many commissions         // as needed.         While...

  • CODE GIVEN % Create a program to plot the motion of the ping pong ball with...

    CODE GIVEN % Create a program to plot the motion of the ping pong ball with drag. % The program will take inputs for velocity in m/s and angle of launch. % note that with a high speed camera I estmated a launch speed for a ping % pong ball could be 30 m/s. vel=30; %m/s angle=60; % convert the degrees into radians so MATLAB likes it angle=angle*pi/180; % set initial values (time, distance, mass, gravity, drag) x(1)=0; % meters...

  • Write a program in Python that computes the interest accrued on an account. You can modify...

    Write a program in Python that computes the interest accrued on an account. You can modify the “futval.py” program given in Chapter 2 to accomplish it. Your program should use a counted loop rather than a formula. It should prompt the user to enter the principal amount, the yearly interest rate as a decimal number, the number of compounding periods in a year, and the duration. It should display the principal value at the end of the duration. To compute...

  • (I would like this to be in five parts.) Write a program (Python module) that includes...

    (I would like this to be in five parts.) Write a program (Python module) that includes a function named studentrecords. This function must support execution of two loops. The first loop is to query the user whether they wish to enter additional records or not. It must accept responses of either yes or no as input, regardless of the letter-cases used for individual letters in the response. If the response is not recognized ( it isn’t yes or no) it...

  • 12. Bar Chart Write a program that asks the user to enter today’s sales for five...

    12. Bar Chart Write a program that asks the user to enter today’s sales for five stores. The program should display a bar chart comparing each store’s sales. Create each bar in the bar chart by displaying a row of asterisks. Each asterisk should represent $100 of sales. Here is an example of the program’s output: Enter today's sales for store 1: 1000 [Enter] Enter today's sales for store 2: 1200 [Enter] Enter today's sales for store 3: 1800 [Enter]...

  • For this assignment, write a program that will generate random numbers in the range of 50-100...

    For this assignment, write a program that will generate random numbers in the range of 50-100 and count how many fall into particular ranges. Processing: The program should first seed the random number generator. This is done one time in the program. Use srand(0). Next, generate and display a series of 10 random numbers between 50 and 100. There are several ways to ensure that a random number falls between 50 and 100. One possibility is to use the following...

  • TASK: C programming Create a program in either visual Studios or an online compiler that will...

    TASK: C programming Create a program in either visual Studios or an online compiler that will use the modern lift equation to calculate the average litt force of input values provided below. The modern lift formular L-a" I. - lift in Newtons air density in kg/m3 V = velocity in m/s 4 - Wing area in m CL = 2 x Pl x angel of the wing This formula is used to calculate the lift produced by airplane wings. You...

  • Challenge: C# Basics Description: Write a C# console application using .NET Core that utilizes constants, variables,...

    Challenge: C# Basics Description: Write a C# console application using .NET Core that utilizes constants, variables, data types, operators, expressions, statements, blocks, and control flow. Purpose: This application provides experience in working with basic language features of C#. It is important when working with a new language to understand how it handles its constants, variables, data types, operators, expressions, statements, blocks, and control flow. A good thing to always do with a new language is to build test applications where...

  • C++ should be used C++ should be used CSC1101 TakeHome Lab02 (1),docx - Compatibility Mode Saved to this PC s Review View Help ρ Search 3. [11] You have been hired by Projectile Objects to cre...

    C++ should be used C++ should be used CSC1101 TakeHome Lab02 (1),docx - Compatibility Mode Saved to this PC s Review View Help ρ Search 3. [11] You have been hired by Projectile Objects to create a calculator for various equations from kinematics. Suppose someone shoots an object and it does projectile motion with an angle of 30, 45 and 60 degrees to the horizontal. Choose it's initial velocity (ex. 10 m/s) find the maximum height it can reach, horizontal...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT