One of the most popular kinematic equations is the one for final velocity: vf =
ID: 645352 • Letter: O
Question
One of the most popular kinematic equations is the one for final velocity: vf = vi + a*t, where vf = final velocity, vi = initial velocity, a = acceleration and t = time. Write a java method that calculates this formula given the arguments. Then in your main, ask the user to input the initial velocity and acceleration for 2 items. Finally, output their increasing velocities over 10 timesteps, calling your method in each iteration. Example Output: Enter the initial velocity of item 1: 10 Enter the acceleration of item 1: 4 Enter the initial velocity of item 2: 3 Enter the acceleration of item 2: 6 After 1 timestep: Item 1's velocity = 14, Item 2's velocity = 9 After 2 timesteps: Item 1's velocity = 18, Item 2's velocity = 15 . . . and so on until 10 timesteps
Explanation / Answer
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string exit;
float Vi;
float Vf;
float d;
float a;
float t;
int variable1;
int variable2;
int variable3;
cout << "Hello, and welcome to the kinematics equation solver program! ";
cout << "This program was made and developed by (my name )! Enjoy! ";
cout << "Let's get started! What three variable do you currently know from the problem? ";
cout << "Tell me one variable at a time! Type the number to the corresponding variable. ";
cout << " 1.) Initial Velocity 2.) Final Velocity 3.) Distance 4.) Acceleration 5.) Time ";
cin >> variable1;
if ( variable1 == 1 )
{
cout << "Good, so you have the initial velocity. Please tell me what the initial velocity is now ";
cin >> Vi;
cout << "Okay, so the initial velocity is "; cout << Vi;
cout << " Now please give me the next variable ";
cout << " 1.) Final Velocity 2.) Distance 3.) Acceleration 4.) Time ";
cin >> variable2;
if ( variable2 == 1 )
cout << "Okay, good so you also have the final velocity ";
cout << "Please enter what the final velocity is now ";
cin >> Vf;
cout << "Okay, so the final velocity is ";
cout << Vf;
cout << " Now please give me the next variable ";
cout << " 1.) Distance 2.) Acceleration 3.) Time ";
cin >> variable3;
if ( variable3 == 1 )
cout << "Okay, so you have initial velocity, final velocity, and distance. ";
cout << "Please enter the distance now ";
cin >> d ;
cout << " Okay, so your distance is" << d;
cout << " We will now find the remaining two variables together! ";
cout << "But always remember your kinematic equations! ";
cout << "For this problem we will use the two equations Vf^2 = Vi^2 + 2ad Vf = Vi + at ";
float a = Vf * Vf - Vi * Vi / d * 2;
cout << "Your acceleration is"; cout << a ;
cout << " Your Time is"; cout << Vf - Vi / a ;
cout << " Thank you for using my program, and I hope this helped! ";
cout << "Never forget these important equations and GO PHYSICS!";
cin >> exit;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.