#include <stdio.h>
#include <math.h> 

#define G 9.81
#define Num_Values 3

 
typedef struct//structure that has three values the user inputs
  {
    double weight;
    double drag;
    double tf; //final time
  }USER_INPUT; 

void calculateVelocities (USER_INPUT inputPtr, double*velocities)  
{
    //calculate velocity at three times each velocity value stored in array [0] [1] [2] declared in main.

    int i; //to go through the array
    double time;
    double interval = inputPtr.tf/Num_Values; 
    printf("Time\tVelocity\n");
    printf("------------------\n");

    for(i=0; i<Num_Values; i++)
    { 
        time = interval+(i*interval);   
        velocities[i] = ((G*inputPtr.weight)/inputPtr.drag)*(1-exp((-(inputPtr.drag/inputPtr.weight)*time)));  
        
        printf("%.2lf\t%.2lf\n", time, velocities[i]);      
    }
}

void getInput (USER_INPUT *input)  //gets values from the user
{
    printf("please enter the weight: ");
    fflush(stdout);
    scanf("%lf", &input->weight); 

    printf("please enter the drag: ");
    fflush(stdout);
    scanf("%lf", &input->drag);

    printf("please enter the time: ");
    fflush(stdout); 
    scanf("%lf", &input->tf);    
}

int main() 
{
    USER_INPUT input; 
    
    getInput(&input); 

    double velocities[Num_Values]; // array for storing the velocites calculated
    //pointer to velocity?   
    
    calculateVelocities(input, velocities); //need to call the pointer 

    //call function calculate velocitiy
}