C Programming

I don't know what to do now. Below is my code I have so far but I have no idea what to do next. Here's the prompt for what the program should do: Welcome to the Weather Balloon Altitude and Velocity Program. Enter the Balloon's Starting Time: 1 Enter the Time Increment: 2.2 Enter the Balloon's Ending Time: 10 ~> more balloon.dat Weather Balloon Information Time (hr) Altitude (m) Velocity (m/s) 1.00 3951.88 0.94 3.20 9829.43 0.56 5.40 13066.73 0.27 7.60 14298.57 0.05 9.80 14092.26 -0.10 Peak Altitude: 14298.57 (m) Corresponding Time: 7.6 hr Assume that the following polynomial representation represents the altitude or height in meters during the first 48 hours following the launch of a weather balloon: h(t) = -0.12t4 + 12t3 – 380t2 + 4100t +220, where the units of t are in hours. The corresponding polynomial model for the velocity in meters/hr of the weather balloon is: v(t) = -0.48t3 + 36t2 -760t + 4100. Write a program that will print a table of the time, altitude, and the velocity for this weather balloon using units of m and m/s. Let the user enter the start time, the increment in time between lines of the table, and the ending time, where all the time values must be less than 48 hours. After your table is printed out, also print the peak altitude and its corresponding time to a file called balloon.dat. Specifications: The format for your output table numbers should be %6.2f for the time, and %9.2f for both the altitude and velocity information. To format your table, use the “\t” (tab) character. For instance, you can use a statement similar to: printf(“%6.2f\t\t%9.2f\t%9.2f\n”,time,altitude,velocity); Here's my code I typed up so far: /* Directives */ #include #define FILENAME "balloon.dat" int main(void) { float startingtime, timeincrement, endingtime, height, velocity; FILE *balloon; /* Open file. */ balloon = fopen(FILENAME,"b"); printf("Welcome to the Weather Balloon Altitude and Velocity Program.\n"); printf("\n"); printf("Enter the Balloon's Starting Time: "); scanf("%f", &startingtime); printf("Enter the Time Increment: "); scanf("%f", &timeincrement); printf("Enter the Balloon's Ending Time: "); scanf("%f", &endingtime); /* Close file. */ fclose(balloon); /* End Program */ return(0); }

Answers

Your program should use the given polynomial equations and the starting, time increment, and ending times as entered by the user to calculate the height and velocity for each time given in the range specified by the user. Once these values have been calculated, you can write the time, altitude and velocity data to the "balloon.dat" file. You can use a for loop to keep track of the time values for each iteration. Within the for loop, you can use calculations based on the polynomial equations to calculate the altitude and velocity at each time. After the for loop is complete and all the data has been written to the file, you can use additional code to find the peak altitude and corresponding time values, and then print them to the same file.

Answered by sullivandouglas

We have mentors from

Contact support