Question

Using C programming Description: You have been tasked to design an application for an engineering...

Using C programming

Description: You have been tasked to design an application for an engineering firm to measure the performance of their vehicle designs. The user, an engineer will enter data into your program when prompted and will perform the required calculation and output the answer. The formula used for this project calculates the distance an object will cover in meters given an initial velocity, a rate of acceleration and a time of acceleration or travel.

1. Your program must declare three functions using function prototypes.

2. The first function should be called “PrintInstructions”

3. This function takes no arguments and returns an int or Boolean value, which the caller can use to determine if the user wishes to quit (entered ‘q’ or ‘Q’) the program or continue (any other character). This will require an if/else decision in your main function.

4. The second function should be called “GetData”.

5. This function must use pointers to get the required inputs (time, velocity, and acceleration) from the user and store the values in the caller’s local variables in main (upward communication).

6. The third function is called “AccelerationDisplacement”

. 7. This function will take parameters by value from the caller in main and calculate the distance an object will travel given time, initial velocity and acceleration and return the calculated value as a type double to the caller.

8. The function should perform the calculation of the formula given. You may use the pow() function pp 191 of the text.

9. The final function is called PrintOutput.

10. This function is called with a value argument and prints the formatted output to the user with the calculations as shown in the required outputs below. The program should then end gracefully.

Formulas: The formula to determine the distance travelled by an accelerating body is shown below. This is a physics kinematics formula. d = displacement (distance) vi = initial velocity t = time a = accelerations d = (vi • t) + (½ • a) •

0 0
Answer #1
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int PrintInstructions(void);
void GetData(float*, float*, float*);
double AccelerationDisplacement(float, float, float);
void PrintOutput(double, float, float, float);

int main() {
        char c;
        float time, velocity, acceleration;
        double d;
        while(1){
                fflush(stdin);
                c = PrintInstructions();
                if (c == 'q' || c == 'Q')
                        break;
                GetData(&time, &velocity, &acceleration);
                d = AccelerationDisplacement(time, velocity, acceleration);
                PrintOutput(d, time, velocity, acceleration);
        }
        printf("Press any key to exit....");
        getch();        
        return 0;
}
int PrintInstructions() {
        char x;
        printf("\n/************************************/\n");
        printf("Welcome to performance calculator app\n");
        printf("Please follow the instructions to provide input data for calculation.\n");
        printf("If you are done using it, enter 'q' or 'Q' to quit the app.\n");
        printf("Do you want to proceed with the app? ");
        
        scanf(" %c", &x);           //Whitespace before %c is necessary to eat any remainng whitespace in stream
        
        return x;
}
void GetData(float *time, float* velocity, float *acceleration) {
        printf("Enter time(in sec): ");
        scanf("%f", time);
        printf("Enter velocity(in m/s): ");
        scanf("%f", velocity);
        printf("Enter acceleration(in m/s^2): ");
        scanf("%f", acceleration);
}
double AccelerationDisplacement(float time, float velocity, float acceleration) {
        return velocity*time + 0.5*acceleration*time*time;
}
void PrintOutput(double d, float time, float velocity, float acceleration) {
        printf("Time(s): %f Velocity(m/s): %f Acceleration(m/s^2): %f Distance(m): %lf\n", time, velocity, acceleration, d);
}

Know the answer?
Add Answer to:
Using C programming Description: You have been tasked to design an application for an engineering...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using MATLAB. As an engineer working on designing and modelling a new drone product, you are...

    Using MATLAB. As an engineer working on designing and modelling a new drone product, you are doing a lot of different physics calculations. Your boss wants to write a program that can choose from an assortment of calculations and perform the desired physics calculation in order to streamline the design and modelling process. For this project you will write a function called PhysicsCalc. inputs Your function should take three inputs in the following order: var1–The first number in the calculation...

  • MAT LAB: write a program that can choose from an assortment of calculations and perform the...

    MAT LAB: write a program that can choose from an assortment of calculations and perform the desired physics calculation in order to streamline the design and modelling process. Your function should take three inputs in the following order: var1 – The first number in the calculation you want to perform. var2 – The second number in the calculation you want to perform var3 – The third number in the calculation you want to perform indicator . A variable, that has...

  • In this program, you will be using C++ programming constructs, such as functions. main.cpp Write a...

    In this program, you will be using C++ programming constructs, such as functions. main.cpp Write a program that asks the user to enter an integer value. Your program will then display that integer back to the user. Your program should include a function called getInteger that requests an integer value from the user and returns that value back to the caller. Your main () function will call the function getInteger and will then display the value returned by that function....

  • i want the code and the answer to last image question#4 please By the way, we...

    i want the code and the answer to last image question#4 please By the way, we need to print values for velocity, acclaration, mass, all of the values This program will prompt the user for the following input The distance an object traveled from point 1 to point 2 (variable distance) The time required to travel distance (variable time) The object's initial velocity (variable initVelocity) . The mass of the object (variable mass) You will need to write a series...

  • Using C programming For this project, you have been tasked to read a text file with student grade...

    Using C programming For this project, you have been tasked to read a text file with student grades and perform several operations with them. First, you must read the file, loading the student records. Each record (line) contains the student’s identification number and then four of the student’s numerical test grades. Your application should find the average of the four grades and insert them into the same array as the id number and four grades. I suggest using a 5th...

  • c++ if you answer the question please write it line by line and not in paragrapth...

    c++ if you answer the question please write it line by line and not in paragrapth form. Write a C++ program that uses a structure named Movie to store the following. a. Title b. Director c. Year Released d. Running time (in minutes) e. Cost of production f. Revenue (first year). Create an array of type Movie of size 3. In your main program should then have in a loop (3 times) called a function called getData() and the purpose...

  • Before you start doing this code Read carefully there is a format that you have to...

    Before you start doing this code Read carefully there is a format that you have to follow HERE IS THE FORMAT YOU MUST USE FOR HW #2 - NOTE THE IF ELSE IF...not IF IF IF HW #2 Format : Instructions: This program will generate some information for a user about interplanetary travel (pretend we can travel easily to other planets for this problem). This program will perform calculations concerning weight on various planets as well as travel time between...

  • PYTHON HOMEWORK When an object is falling because of gravity, the following formula can be used...

    PYTHON HOMEWORK When an object is falling because of gravity, the following formula can be used ot determine the distance the object falls during a specific time period: d=1/2 g t^2 The variables in the formula are as follows: d is the distance in meters(m), g is the acceleration due to gravity, an and its value is 9.8 m/s^2, t is the time duration in seconds(s). Write a function named falling_distance() that accepts an object's falling duration(time) in seconds as...

  • C++ The roots of the quadratic equation ax² + bx + c = 0, a ≠...

    C++ The roots of the quadratic equation ax² + bx + c = 0, a ≠ 0 are given by the following formula: In this formula, the term b² - 4ac is called the discriminant. If b² - 4ac = 0, then the equation has a single (repeated) root. If b² - 4ac > 0, the equation has two real roots. If b² - 4ac < 0, the equation has two complex roots. Instructions Write a program that prompts the...

  • C++ LANGUAGE The following formula can be used to determine the distance an object falls in...

    C++ LANGUAGE The following formula can be used to determine the distance an object falls in a specific time period: d = 1 2 g t 2 where d is the distance in meters, g is 9.8, and t is the amount of time, in seconds, the object has been falling. Write a function named fallingDistance that accepts an object's falling time in seconds as an argument. You must define a named constant for g using a meaningful name and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT