Question
Please, write the answer in C+ For this program you will build a modular equation evaluator (you may want to start from your solution to
Please, write the answer in C+
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 to the equations and evaluate them based on the inputs. 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, and variable a are floating-point values. The plaintext_character and encoded_character variables are characters, and the a variable is an integer. PI must be defined as a constant macro (#defined constants). Error checking is not required for your program. You do not need to check for faulty user input or dividing by zero.
1. Newtons 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' (note: what happens if plaintext_character is lowercase?)
4. Gauss Lens Formula (solve for f): 1 / f = 1 / u + 1 / v, where u is the object distance, v is the image distance, and f is the focal length of the lens
5. Tangent: tan_theta = sin (theta) / cos (theta) (recall: find the appropriate functions in
6. Resistive divider: vout = r2 / (r1 + r2) * vin
7. Distance between two points: distance = square root of ((x1 - x2)2 + (y1 - y2)2) (note: you will need to use sqrt ( ) out of
8. General equation: y = a / (a % 2) - (63 / -17) + x * z (recall: a is an integer; the 63 and -17 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: these are your required function prototypes or declarations!):
1. double calculate_newtons_2nd_law (double mass, double acceleration)
2. double calculate_volume_cylinder (double radius, double height)
3. char perform_character_encoding (char plaintext_character)
4. double calculate_gauss_lens (double u, double v)
5. double calculate_tangent (double theta)
6. double calculate_resistive_divider (double r1, double r2, double vin)
7. double calculate_distance_between_2pts (double x1, double y1, double x2, double y2)
8. double calculate_general_equation (int a, double x, double z)
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, nor display the result. Prompts and displaying results should be performed in main ( ).
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/declarations. 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 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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started