HW   day 11       10/4/2018

1   Write a program that will print a table of the altitude and the velocity for this weather balloon using units of meters and meters per second. 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. Use the program to generate a table showing the weather balloon information every 10 minutes over a 2-hour period, starting 4 hours after the balloon was launched.
#include<stdio.h>

#include<math.h>

int main(void)

{

// declare the variables

double ini_time, inc_time, Ed_time, time, h, v;

// for question 2

double max_h=0, max_time=0;

do{

// read the input

printf(" \nEnter the values of the table \n");

printf("\n Enter start time \n");

scanf("%lf",&ini_time);

printf(" Enter incresement time \n");

scanf("%lf",&inc_time);

printf(" Enter ending time \n");

scanf("%lf",&Ed_time);

// checking finall time

if (ini_time> Ed_time)

{printf("warning!!! the ending time is less than the start time\n ");}}

// if it true, the program will continous

while(Ed_time< ini_time);
{
printf("\n\n information of weather ballon \n");

printf(" time height velocity \n");

printf(" hours meters meters/s \n");

// loop

for (time = ini_time; time <= Ed_time; time+=inc_time)

{

//solve for height

h=(-0.12*pow(time,4)+(12*pow(time,3))-(380*time*time)+(4100*time)+220);

// solve for velocity

v= -0.48*pow(time,3)+(36*time*time)-(760*time)+4100;

printf("%5.2f% 11.2f% 9.2f\n", time, h, v/3600);



// question 2 find peak altitude

if (h> max_h)

{ max_h=h;

max_time=time;}}

printf("\n the max height is % 10.2f meters\n", max_h);

printf(" at the time t= %5.2f hours\n",max_time);}



return 0;

}
d/ >48
#include<stdio.h>
#include<math.h>
int main(void)
{
// declare the variables
double ini_time, inc_time, Ed_time, time, h, v;
// for question 2
double max_h=0, max_time=0;
do{
  // read the input
printf(" \nEnter the values of the table \n");
  printf("\n Enter start time \n");
  scanf("%lf",&ini_time);
  printf(" Enter incresement time \n");
  scanf("%lf",&inc_time);
  printf(" Enter ending time \n");
  scanf("%lf",&Ed_time); 
// checking finall time
  if (ini_time>48 || Ed_time>48)
  {printf("warning!!! the time is outside the domain\n ");}}
// if it true, the program will continous
  while(Ed_time>48|| ini_time>48);
  printf("\n\n information of weather ballon \n");
  printf(" time     height    velocity \n");
  printf(" hours    meters    meters/s \n");
// loop
  for (time = ini_time; time <= Ed_time; time+=inc_time)
  {
  //solve for height 
  h=(-0.12*pow(time,4)+(12*pow(time,3))-(380*time*time)+(4100*time)+220);        
// solve for velocity
    v= -0.48*pow(time,3)+(36*time*time)-(760*time)+4100;
  printf("%5.2f%    11.2f%    9.2f\n", time, h, v/3600);
  }
// question 2 find peak altitude
if (h> max_h)
{ max_h=h;
max_time=time;}
printf("\n the max height is % 10.2f meters\n", max_h);
printf(" at the time t= %5.2f hours\n",max_time);


  return 0;
}
e
#include<stdio.h>
#include<math.h>
#define FILENAME "Mtsacballoon.txt"
int main(void){
// declare the variables
double ini_time, inc_time, Ed_time, time, h, v;
// for question 2
double max_h=0, max_time=0;
FILE*Mtsacballon;
Mtsacballon = fopen(FILENAME, "w");
do{
// read the input
printf(" \nEnter the values of the table \n");
printf("\n Enter start time \n");
scanf("%lf",&ini_time);
printf(" Enter incresement time \n");
scanf("%lf",&inc_time);
printf(" Enter ending time \n");
scanf("%lf",&Ed_time);
// checking finall time
if (ini_time>48 || Ed_time>48)
{printf("warning!!! the time is outside the domain\n ");}}
// if it true, the program will continous
while(Ed_time>48|| ini_time>48);
printf("\n\n information of weather ballon \n");
printf(" time height velocity \n");
printf(" hours meters meters/s \n");
// loop
for (time = ini_time; time <= Ed_time; time+=inc_time)
{{
//solve for height
h=(-0.12*pow(time,4)+(12*pow(time,3))-(380*time*time)+(4100*time)+220);
// solve for velocity
v= -0.48*pow(time,3)+(36*time*time)-(760*time)+4100;
printf("%5.2f% 11.2f% 9.2f\n", time, h, v/3600);
if (h> max_h)
{ max_h=h;
max_time=time;}}
// question 2 find peak altitude
//write values
fprintf(Mtsacballon,"%5.2f%10.2f%7.2f\n",time,h,v/3600);}
printf("\n the max height is % 10.2f meters\n", max_h);
printf(" at the time t= %5.2f hours\n",max_time);
fclose(Mtsacballon);
return 0;
}

Comments

Popular posts from this blog