Question

For this program you will build a modular equation evaluator (you may want to start from your solution to programming assignment 1). Once again, you will write a C program that evaluates the equations provided below. The program must prompt the user for inputs for the equations and evaluate them based on the inputs. All equations should be placed into a single .c file. This means you should NOT have 7 Visual Studio projects or 7 .c files. All variables on the right hand sides of the equations must be inputted by the user. All variables, except for the plaintext_character, encoded_character, variable a, shift, R1, R2, and R3 are floating-point values. The plaintext_character and encoded_character variables are characters, and the a, shift, R1, R2, and R3 variables are integers. PI should be defined as a constant macro (#defined constant). Error checking is not required for your program. You also do NOT need to check for faulty user input. However, please consider inputs that could cause your program to work incorrectly.

  1. Newton’s Second Law of Motion: force = mass * acceleration
  2. Volume of a cylinder: volume_cylinder = PI * radius2 * height
  3. Character encoding: encoded_character = (plaintext_character - 'A') + 'a' - shift; shift is an integer (note: what happens if plaintext_character is uppercase? What happens with various shift keys?)
  4. Distance between two points: distance = square root of ((x1 - x2)2 + (y1 - y2)2) (note: you will need to use sqrt ( ) out of <math.h>)
  5. Tangent: tan_theta = sin (theta) / cos (theta) (recall: find the appropriate functions in <math.h>)
  6. Total resistance of resistors in paralell: total_resistance = 1 / (1 / R1 + 1 / R2 + 1 / R3), for 3 resistors. R1, R2, and R3 are integers.
  7. General equation: y = (2 / 3) - y + z * x / (a % 2) + PI (recall: a is an integer; the 2 and 3 constants in the equation should be left as integers initially, but explicitly type-casted as floating-point values)

For this assignment you are required to define, at a minimum, the functions provided below (note: the first 5 are your required prototypes for those functions!):

*double calculate_newtons_2nd_law (double mass, double acceleration)

*double calculate_volume_cylinder (double radius, double height)

*char perform_character_encoding (char plaintext_character, int shift)

*double calculate_distance_between_2pts (double x1, double x2, double y1, double y2)

*double calculate_tangent_theta (double theta)

*A function for calculating total parallel resistance (you must decide on a name, return type, and parameter list!)

*A function for calculating the general equation (once again, you must decide on a name, return type, and parameter list!)

A function must be defined for each of the above function signatures. The task that is performed by each function corresponds directly to the equations defined under the Equations section. For example, the calculate_newtons_2nd_law ( ) function should evaluate the equation defined as force = mass * acceleration and return the resultant force, etc. You must print the results to the hundredths place. Also, the functions should not prompt the user for inputs. Prompts should be performed in main ( ) directly.

For this assignment you will need to define three different files. One file, called a header file (.h) needs to be defined which will store all #includes, #defines, and function prototypes. Name the header file for this assignment equations.h. The second file that needs to be defined is just a C source file. This file should be named equations.c and include all function definitions for the above functions. The last file that should be defined is the main.c source file. This file will contain the main ( ) function or driver for the program.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

IF YOU HAVE ANY DOUBTS COMMENT BELOW I WILL BE THERE O HELP YOU

ANSWER:

CODE:

/* including whatever system libraries are required */
#ifndef LIBRARAY_H
#define LIBRARAY_H

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

#endif

/* Defining constant PI */
#define PI 3.14;

/* Defining function signatures for our program */
#ifndef EQUATIONS_H
#define EQUATIONS_H

   //defining out functions
   double calculate_newtons_2nd_law (double mass, double acceleration);
   double calculate_volume_cylinder (double radius, double height);
   char perform_character_encoding (char plaintext_character);
   double calculate_gauss_lens (double u, double v);
   double calculate_tangent (double theta);
   double calculate_resistive_divider (double r1, double r2, double vin);
   double calculate_distance_between_2pts (double x1, double y1, double x2, double y2);
   double calculate_general_equation (int a, double x, double z);

#endif


/******************************* FILE EQUATIONS.C **************************/
#include "equations.h"

double calculate_newtons_2nd_law (double mass, double acceleration) {
   return mass * acceleration;
}
double calculate_volume_cylinder (double radius, double height) {
   return pow(radius, 2) * height * PI;
}
char perform_character_encoding (char plaintext_character) {
   return (plaintext_character - 'a') + 'A';
}
double calculate_gauss_lens (double u, double v) {
   return 1.0 / (1.0 / u + 1.0 / v);
}
double calculate_tangent (double theta) {
   return sin(theta) / cos(theta);
}
double calculate_resistive_divider (double r1, double r2, double vin) {
   return (r2 * vin) / (r1 + r2) ;
}
double calculate_distance_between_2pts (double x1, double y1, double x2, double y2) {
   return sqrt(pow(x1 -x2, 2) + pow(y1 -y2, 2));
}
double calculate_general_equation (int a, double x, double z){
   return (double)a / (a % 2) - (63 / -17) + x * z;
}

/***************************** MAIN.C *************************************/
#include "equations.h"

int main()
{
printf("Newton's Law value: %f\n", calculate_newtons_2nd_law(2.5, 3.0));
printf("volume_cylinder : %f\n", calculate_volume_cylinder (2, 4));
  
return 0;
}

RATE THUMBSUP PLEASE

THANKS

Add a comment
Know the answer?
Add Answer to:
For this program you will build a modular equation evaluator (you may want to start from...
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
  • Complete the functions for the program complex.c (Down) . The program adds, subtracts,and multiplies complex numbers....

    Complete the functions for the program complex.c (Down) . The program adds, subtracts,and multiplies complex numbers. The C program will prompt the user for the choice of operations,read in the complex numbers, perform the operations, and print the results. The main programrepeatedly prints the menu, reads in the user’s selection, and performs the operation. We use pointers only for those arguments that the function intends to change. In all thefunctions, r represents the real component and i represents the imaginary...

  • C++ Addition of Complex Numbers Background Knowledge A complex number can be written in the format of , where and are real numbers.   is the imaginary unit with the property of .   is called the r...

    C++ Addition of Complex Numbers Background Knowledge A complex number can be written in the format of , where and are real numbers.   is the imaginary unit with the property of .   is called the real part of the complex number and   is called the imaginary part of the complex number. The addition of two complex numbers will generate a new complex number. The addition is done by adding the real parts together (the result's real part) and adding the...

  • a) By direct substitution determine which of the following functions satisfy the wave equation. 1. g(x,...

    a) By direct substitution determine which of the following functions satisfy the wave equation. 1. g(x, t) = Acos(kx − t) where A, k, are positive constants. 2. h(x, t) = Ae where A, k, are positive constants. 3. p(x, t) = Asinh(kx − t) where A, k, are positive constants. 4. q(x, t) = Ae where A, a, are positive constants. 5. An arbitrary function: f(x, t) = f(kx−t) where k and are positive constants. (Hint: Be careful with...

  • You are provided with the following gray-scale images below: Task Replicate the results that are shown...

    You are provided with the following gray-scale images below: Task Replicate the results that are shown in each of the Figures using the image enhancement methods exploited to generate those results. You are to write user-defined functions to implement the enhancement techniques and of course a script to call the functions. Summary of the Technique: Comparison of various techniques: For the sake of comparison, apply the techniques to the image data (ImAerialGS) and comment on the results. We were unable...

  • III. Overview & Requirements: The following description has been adopted from Deitel & Deitel. One of...

    III. Overview & Requirements: The following description has been adopted from Deitel & Deitel. One of the most popular games of chance is a dice game called "craps," which is played in casinos and back alleys throughout the world. The rules of the game are straightforward: A player rolls two dice. Each die has six faces. These faces contain 1, 2, 3, 4, 5, and 6 spots. After the dice have come to rest, the sum of the spots on...

  • 4. When critiquing a descriptive study, which of the following would you expect to find in...

    4. When critiquing a descriptive study, which of the following would you expect to find in the study report? A discussion of the variables of interest and how they are defined A well-written directional hypothesis that describes the proposed relationship between the variables under study Evidence of a random assignment to groups Manipulation of the independent variable 5. Which of the following is (are) true about an independent variable? Select all that apply. It is known as the treatment or...

  • This image is displaying on my end. I am not sure why you are not able...

    This image is displaying on my end. I am not sure why you are not able to see it. It is a square image with a plus and minus symbol on the left. 5 zigzag lines going down the middle, R1, R2, R3, R4, R5 starting from the left We were unable to transcribe this imageDetermine the total current in the circuit below, if RI-3Ω , R2-SQ,R3- 70, R4 90, R3 11Ω and the battery source has 18V

  • You must write a C program that prompts the user for two numbers (no command line...

    You must write a C program that prompts the user for two numbers (no command line input) and multiplies them together using “a la russe” multiplication. The program must display your banner logo as part of a prompt to the user. The valid range of values is 0 to 6000. You may assume that the user will always enter numerical decimal format values. Your program should check this numerical range (including checking for negative numbers) and reprompt the user for...

  • Let X1, X2, ..., Xn be a random sample of size n from the distribution with...

    Let X1, X2, ..., Xn be a random sample of size n from the distribution with probability density function To answer this question, enter you answer as a formula. In addition to the usual guidelines, two more instructions for this problem only : write   as single variable p and as m. and these can be used as inputs of functions as usual variables e.g log(p), m^2, exp(m) etc. Remember p represents the product of s only, but will not work...

  • Dear, can you please right a sign next to the needed answer ? H e will...

    Dear, can you please right a sign next to the needed answer ? H e will be recognised as Euler's number. • Use to explicitly indicate multiplication between variables and other variables, between variables and brackets, or betwe (e.g. x'y rather than xy, 2*(x+y) rather than 2(x+y)) . Put arguments of functions in brackets (e.g. sin(x) rather than sin x). Let g(z,y) = –2-23-2-22 +4.72 +3. Show/hide sin(a) too a 2 Back Quit & Save Submit Assignment Show/hide sin (a)...

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