Help with a C program I am working on!! I have this problem I am trying to solve
ID: 673908 • Letter: H
Question
Help with a C program I am working on!!
I have this problem I am trying to solve: When cargo is being dropped to remote locations, it is strapped to a parachute and then released. If the parachute is not large enough, the contents of the cargo can be smashed and broken. Ideally, a fall between 14 and 15 feet per second will result in a "soft" landing without damage to cargo. This also works for smaller objects as well. In order to demonstrate this, I will construct a "program" where the user enters the weight of the cargo in ounces, and then has five tries to get the size of parachute to be adequate in order to have the cargo drop at a rate between 14 and 15 feet per second. If the chute is too big, then the rate of descent is too slow and that won't work. If the chute is not big enough, it hits the ground with a SPLAT!!!
I must include the following functions:
float GetCargo( ) ---This function will return a positive number of ounces for the cargo.
float GetChuteSize ( int count ) ---This function will return a positive number for the chute size (square feet). The parameter passed to the function is the "try number". It will be a value between 1 and 5).
float Computefps (float weight, float size) -- This function will compute and display the rate of descent. The speed is returned. The formula is explained below. The two parameters passed to it are the weight of the cargo and the size of the chute. You can define other functions to use besides these three.
I must define constants for any numbers I use in the program other than 0 and 1!
This is a sample program output:
Enter weight of cargo in ounces: 1000
Try 1
Enter chute size in square feet: 100
Falling at 34.959 feet/sec.
SPLAT!!!!...You need a bigger chute
Try 2
Enter chute size in square feet: 200
Falling at 17.4795 feet/sec.
SPLAT!!!!...You need a bigger chute
Try 3
Enter chute size in square feet: 300
Falling at 11.653 feet/sec.
TOO SLOW...Drifting too much...you need a smaller chute.
Try 4
Enter chute size in square feet: 250
Falling at 13.9836 feet/sec.
TOO SLOW...Drifting too much...you need a smaller chute.
Try 5
Enter chute size in square feet: 240
Falling at 14.5662 feet/sec.
Nice landing!!!
Explanation / Answer
#include<stdio.h>
float GetCargo(){
float c;
printf("Enter the weight of the cargo: ");
scanf("%f",&c);
return c;
}
float GetChuteSize(int count){
printf("Try %d ",count);
float size;
printf("Enter the chute size in square feet: ");
scanf("%f",&size);
return size;
}
float Computefps(float weight,float size){
float fps=14.5;//you havent mentioned the formula
return fps;
}
int main(){
float weight=GetCargo();
int count=1;
float fps,size;
int flag=0;
while(flag==0){
size=GetChuteSize(count);
fps=Computefps(weight,size);
if(fps>15.0){
printf("falling at %f ",fps);
printf("SPLAT!!!!...You need a bigger chute");
}else if(fps<14){
printf("falling at %f ",fps);
printf("TOO SLOW...Drifting too much...you need a smaller chute.");
}else{
printf("falling at %f ",fps);
printf("Nice Landing: ");
flag=1;
}
count=count+1;
}
}
You didnt mention the formula
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.