Computer science Help

help with C language !!

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

PA1/.vs/PA1/v14/.suo

PA1/PA1.sdf

PA1/PA1.sln

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project(“{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}”) = “PA1”, “PA1\PA1.vcxproj”, “{1BEE3BDE-BA47-4918-977E-09FDE4CDED0A}”
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1BEE3BDE-BA47-4918-977E-09FDE4CDED0A}.Debug|x64.ActiveCfg = Debug|x64
{1BEE3BDE-BA47-4918-977E-09FDE4CDED0A}.Debug|x64.Build.0 = Debug|x64
{1BEE3BDE-BA47-4918-977E-09FDE4CDED0A}.Debug|x86.ActiveCfg = Debug|Win32
{1BEE3BDE-BA47-4918-977E-09FDE4CDED0A}.Debug|x86.Build.0 = Debug|Win32
{1BEE3BDE-BA47-4918-977E-09FDE4CDED0A}.Release|x64.ActiveCfg = Release|x64
{1BEE3BDE-BA47-4918-977E-09FDE4CDED0A}.Release|x64.Build.0 = Release|x64
{1BEE3BDE-BA47-4918-977E-09FDE4CDED0A}.Release|x86.ActiveCfg = Release|Win32
{1BEE3BDE-BA47-4918-977E-09FDE4CDED0A}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

PA1/PA1.VC.db

PA1/PA1/main.c
/**************************************************************************************************
* Programmer: Andrew S. O’Fallon *
* Class: CptS 121; Lab Section 0 *
* Programming Assignment: Solution to Programming Assignment #1 – *
* Equation Evaluator *
* Date: *
* *
* Description: This program evaluates seven different equations. *
* The constants represent coefficients and *
* coordinates that are used in the provided equations. *
* The user is prompted to enter the values, and the formulas *
* listed below are evaluated based on the user input. *
* The equations are displayed with the constants and results. *
* *
* Inputs: acceleration, mass_newton, radius, cylinder_height, plaintext_character, *
* mass1, mass2, distance_gravity, x1, x2, y1, y2, theta, r1, r2, *
* vin, x, z, a *
* Constants: PI, G *
* Computations: See relevant formulas *
* Outputs: force_newton, volume_cylinder, encoded_character, *
* force_gravity, vout, distance_points, y *
* *
* This program does not provide error checking and only *
* uses sequential statements. This program defines only one *
* function, main (). *
* *
* Relevant Formulas (The equation numbers are referenced in the comments of *
* the program): *
* (1)Newton’s 2nd Law: force_newton = mass_newton * acceleration *
* (2)Volume of a cylinder: volume_cylinder = PI * radius^2 * cylinder_height *
* (3)Character encoding: encoded_character = (plaintext_character – ‘a’) + ‘A’ *
* (4)Gravity: force_gravity = G * mass1 * mass2 / distance_gravity^2 *
* (5)Resistive divider: vout = r2 / (r1 + r2) * vin *
* (6)Distance between two points: distance_points = square root of ((x1 – x2)^2 + *
* (y1 – y2)^2) *
* (7)General equation: (89 / 27) – z * x + a / (a % 2) *
*************************************************************************************************/
#include /* Include the standard input/output library for functions printf ( ) and scanf ( )*/
#include /* Included for sqrt ( ), sin ( ), and cos ( ) */
#define PI 3.141592 /* Define a constant macro to represent PI for the relevant equations */
#define G 6.67e-11 /* Define a constant macro for the gravitational constant */
int main(void) /* The main ( ) function is the starting point of the program */
{
int a = 0; /* Stores the value for the user inputted a coefficient in equation (7) */
char plaintext_character = ‘\0’, /* Stores the character inputted by the user for use in equation (3) */
encoded_character = ‘\0’; /* Stores the result of the encoding from equation (3) */
double mass_newton = 0.0, /* Stores the mass in grams of the value inputted by the user for equation (1) */
acceleration = 0.0, /* Stores the acceleration in m/s^2 of the value inputted by the user for equation (1) */
force_newton = 0.0, /* Stores the result of equation (1) */
radius = 0.0, /* Stores the radius of the cylinder inputted by the user for equation (2) */
cylinder_height = 0.0, /* Stores the height of the cylinder inputted by the user for equation (2) */
volume_cylinder = 0.0, /* Stores the result of equation (2) */
mass1 = 0.0, /* Stores the mass of one object inputted by the user for equation (4) */
mass2 = 0.0, /* Stores the mass of a second object inputted by the user for equation (4) */
distance_gravity = 0.0, /* Stores the distance between objects inputted by the user for equation (4) */
force_gravity = 0.0, /* Stores the result of equation (4) */
r1 = 0.0, /* Stores the first resistor value entered by the user for equation (5) */
r2 = 0.0, /* Stores the second resistor value entered by the user for equation (5) */
vin = 0.0, /* Stores the input voltage value entered by the user for equation (5) */
vout = 0.0, /* Stores the result of the resisitive divider equation (5) */
x1 = 0.0, /* Stores the x1 value inputted by the user for equation (6) */
x2 = 0.0, /* Stores the x2 value inputted by the user for equation (6) */
y1 = 0.0, /* Stores the y1 value inputted by the user for equation (6) */
y2 = 0.0, /* Stores the y2 value inputted by the user for equation (6) */
distance_points = 0.0, /* Stores the distance between two points computed from equation (6) */
x = 0.0, /* Stores x value inputted by user for equation (7) */
z = 0.0, /* Stores z value inputted by user for equation (7) */
y = 0.0; /* Stores the result of the general equation (7) */
printf(“*************** WELCOME TO THE EQUATION EVALUATOR **************\n\n”);
/* Prompt the user for 2 floating-point values that are used in Netwon’s 2nd Law of Motion
equation (1) */
printf(“Please enter the mass and acceleration (both floating-point values) for use in Newton’s Second Law: “);
/* Read the floating-point values into the proper variables: do not forget the
“address of” operator (&) before each variable */
scanf(“%lf%lf”, &mass_newton, &acceleration);
/* Calculate the result of equation (1), which is force on an object
provided its mass and acceleration */
force_newton = mass_newton * acceleration;
/* Print out the result of equation (1) */
printf(“Newton’s Second Law: force = mass * acceleration = %lf * %lf = %lf\n”,
mass_newton, acceleration, force_newton);

/* Prompt the user for 2 floating-point values that are used in volume of a cylinder
equation (2) */
printf(“\nPlease enter the radius and height (both floating-point values) for use in a volume of cylinder equation: “);
/* Read the floating-point values into the proper variables that are used in equation (2) */
scanf(“%lf%lf”, &radius, &cylinder_height);
/* Calculate the result of equation (2), which is the volume of the cylinder
derived from radius and height of it */
volume_cylinder = PI * radius * radius * cylinder_height;
/* Print out the result of equation (2) */
printf(“Volume of a cylinder: volume_cylinder = PI * radius^2 * height = %lf * %lf^2 * %lf = %lf\n”,
PI, radius, cylinder_height, volume_cylinder);

/* Prompt the user for 1 character value for use in equation (3) */
printf(“\nPlease enter the plaintext character for use in a character encoding equation: “);
/* Read the character into the proper variable that is used in equation (3) */
/* Recall a space between the ” and %c ignores all white space characters */
scanf(” %c”, &plaintext_character);
/* Calculate the result of equation (3), which is the encoded character */
encoded_character = (plaintext_character – ‘a’) + ‘A’;
/* Print out the result of equation (3) */
printf(“Character encoding: encoded_character = (plaintext_character – ‘a’) + ‘A’ = %c – %c + %c = %c\n”,
plaintext_character, ‘a’, ‘A’, encoded_character);

/* Prompt the user for 3 floating-point values that for use in equation (4) */
printf(“\nPlease enter the masses of two objects and the distance between the objects\n”);
printf(” (all floating-point values) for use in gravitational force between two objects equation: “);
/* Read the floating-point values into the proper variables for equation (4) */
scanf(“%lf%lf%lf”, &mass1, &mass2, &distance_gravity);
/* Calculate the result of equation (4), which is the gravitational force */
force_gravity = G * mass1 * mass2 / (distance_gravity * distance_gravity);
/* Print out the result of equation (4) */
printf(“Gravity: force = G * mass1 * mass2 / distance^2\n”);
printf(” = %.12lf * %lf * %lf / %lf^2 = %.12lf\n”, G, mass1, mass2, distance_gravity, force_gravity);

/* Prompt the user for 3 floating-point values that are used in the resistive divider
equation (5) */
printf(“\nPlease enter two resistance values and an input voltage (all floating-point values) for use in\n”);
printf(” resisitve divider equation: “);
/* Read the floating-point values into the proper variables for equation (5) */
scanf(“%lf%lf%lf”, &r1, &r2, &vin);
/* Calculate the ouptut voltage for the resistive divider equation (5) */
vout = r2 / (r1 + r2) * vin;
/* Print out the result of equation (5) */
printf(“Resistive divider: vout = r2 / (r1 + r2) * vin = %lf / (%lf + %lf) * %lf = %lf\n”,
r2, r1, r2, vin, vout);

/* Prompt the user for the coordinates of two points for use in equation (6) */
printf(“\nPlease enter the x1, y1, x2, and y2 (all floating point values) for use in a distance between points equation: “);
/* Read in the floating-point values in the correct order for equation (6) */
scanf(“%lf%lf%lf%lf”, &x1, &y1, &x2, &y2);
/* Calculate the distance between points for equation (6) */
distance_points = sqrt(((x1 – x2) * (x1 – x2)) + ((y1 – y2) * (y1 – y2)));
/* Print out the distance between two points derived from equation (6) */
printf(“\nDistance between 2 pts: distance = sqrt ((x1 – x2)^2 + (y1 – y2)^2)\n”);
printf(” = sqrt ((%lf – %lf)^2 + (%lf – %lf)^2) = %lf\n”, x1, x2, y1, y2, distance_points);

/* Prompt the user for 2 floating-point and 1 integer values to be used
in the general equation calculation (7) */
printf(“\nPlease enter x and z (both floating_point values) and a (an integer value)\n”);
printf(” for use in a general equation: “);
/* Get the values needed for equation (7) */
scanf(“%lf%lf%d”, &x, &z, &a);
/* Calculate the result of equation (7), the result is a y-coordinate */
y = ((double)89 / 27) – z * x + a / (a % 2);
/* Print the result of the general equation (7) */
printf(“general equation: y = 89/27 – z * x + a / (a %% 2)\n = %lf – %lf * %lf + %d / (%d %% 2) = %lf\n\n”, ((double)89 / 27), z, x, a, a, y);

return 0;
} /* End of program */

PA1/PA1/PA1.vcxproj

Debug
Win32

Release
Win32

Debug
x64

Release
x64

{1BEE3BDE-BA47-4918-977E-09FDE4CDED0A}
Win32Proj
PA1
8.1

Application
true
v140
Unicode

Application
false
v140
true
Unicode

Application
true
v140
Unicode

Application
false
v140
true
Unicode

true

true

false

false

Level3
Disabled
WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)

Console
true

Level3
Disabled
_DEBUG;_CONSOLE;%(PreprocessorDefinitions)

Console
true

Level3

MaxSpeed
true
true
WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)

Console
true
true
true

Level3

MaxSpeed
true
true
NDEBUG;_CONSOLE;%(PreprocessorDefinitions)

Console
true
true
true

PA1/PA1/PA1.vcxproj.filters

{4FC737F1-C7A5-4376-A066-2A32D752A2FF}
cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx

{93995380-89BD-4b04-88EB-625FBE52EBFB}
h;hh;hpp;hxx;hm;inl;inc;xsd

{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms

Source Files

Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER