Using C++ 1. Write a program that will compute the distance an object will fall
ID: 3703066 • Letter: U
Question
Using C++ 1. Write a program that will compute the distance an object will fall (traveling down) for times of I second to 15 seconds. The formula is d gt2 where d is the distance in meters, g is 98 (gravity) and t is the amount of time in seconds that the object has been falling. Write a function named fallingDistance' passing in the time as an argument. Print out the time and the distance in table format. The function will NOT have a loop in it. Write a function to print labels and another function to print one line of output 2. I just climb Mt. Everest and I'm looking around enjoying the view and a mighty gust of wind comes up and blows me off the back of the mountain. The drop is 12,000 meters straight down. I want to know how much time I have left before I pull my safety parachute. You are to print out how much timeI have left (before splat) every 500 meters. Print out meters traveled and time remaining in table format. Write a function BeforeSplat passing in the distance. Again, BeforeSplat function does NOT have a loop in it. Write a function to print labels and another function to print one line of output Formula above is now t 3. I trying to save some monies for the future either for myself, my children or grand children. Ilooking at putting in to savings/investments at the beginning of some time and letting it grow with no additional added funds. Write a program to compute the amount of monies I will have after saving for 5 years to 60 years at increments of 5 years. That should do for now. The formula 'future value formula'is F- P x ( 1 x i ) t where F is the future value (monies accumulate) Pis current monies deposited, i is monthly interest (not yearly) and t is number of months for investment. Use an interest rate of 10% per year with an initial investment of S5,000.00 and of S10,000.00 where the years range from 5 yr to 60 yr. Print out in table format with headings. See below number initial initial year S5,000.00 S10,000.00 8,234.00 18,444.00 10 60Explanation / Answer
Solution:
2)
code:
#include<iostream>
#include<math.h>
using namespace std;
float fallingDistance( int dis){
float time = (2*dis)/9.8 ; // since S = 0.5 * g * t^2
time = sqrt(time); // t = sqrt(2S/g)
return time;
}
void printlabel(){
cout<<" distance time"<<endl;
cout<<"-------------------------------"<<endl;
}
void print(float dis, int t){
cout<<" "<<dis<<" "<<t<<endl;
}
int main(){
float time;
printlabel();
// calculateing dist from time 1 to 10 sec.
for(int dis=12000; dis>0; dis = dis- 500){
time = fallingDistance(dis);
print(dis,time);
}
return 0;
}
3)
code:
#include<iostream>
#include<math.h>
using namespace std;
double FutureValue(float prin, int t, double r){
double Mon, test;
test = 1 + r;
Mon = (prin * pow(test, t));
return Mon;
}
void printlabel(){
cout<<"Number initial initial"<<endl;
cout<<"year $5,000.00 $10,000.00 "<<endl;
cout<<"-------------------------------"<<endl;
}
void print(int time, double res1, double res2){
cout<<time<<" "<<res1<<" "<<res2<<endl;
}
int main(){
float i = 0.1;// 10% per year
double rate = (0.1/12); //converting to per month
int act_time;
double In1= 5000, In2 = 10000;
double res1, res2;
printlabel();
for(int t=5; t<= 60 ; t=t+5){
act_time = t*12; // converting years to months
res1 = FutureValue(In1, act_time, rate);
res2 = FutureValue(In2, act_time, rate);
print(t, res1, res2);
}
}
I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.