![]() |
Program I did for a class today...did I do it correctly?
Instructions:
I. The program asks for the user to input the magnitudes and angles (with respect to X-axis) for two vectors, A and B. It then calculates the resultant vector (R) by summing the X- and Y-components of the two vectors, and prints the magnitudes, and angles (with respect to X-axis) of the vectors A, B, and R on the screen in the format given below. II. Helpful Math Hints Rad_A = Deg_A * PI/180 Rx = A cos (rad_A) + B cos(rad_B) Ry = A sin (rad_A) + B sin(rad_B) R = √ (Rx^2 + Ry^2), and rad_R = [atan(Ry/Rx)*180/PI] III. Helpful Programming Hints: 1. Preprocessor define PI = 3.14159 2. Define variables A, B, R, deg_A, rad_A, deg_B, Rad_B, deg_R, rad_R, Rx, Ry as "double/or float" 3. Ask user to enter A in newtons, read the value and assign to A; ask to enter deg_A in degrees, read the value (scan in lf format/or float number as appropriate) and assign to deg_A, and so on...for all the input variables. 4. Computer the rad_A, rad_B, and computer the components (Rx and Ry) of the resultant (R): 5. Computer the resultant vector's magnitude: R = √ (Rx^2 + Ry^2) 6. Compute the resultant vector's directions in degrees: :
#include <stdio.h> |
Re: Program I did for a class today...did I do it correctly?
Why don't you tell me?
It looks promising, but you have a typo on your last printf statement. Literals are terminated with a quotation mark. Not a colon. See what happens when you input: :
1You get an answer in the first quadrant. The answer should be in the third quadrant (225) with magnitude sqrt(2). Do you need to account for this? |
| All times are GMT -5. The time now is 3:55 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC