At Acme, they produce widgets. Widgets consist of two primary parts: a square wh
ID: 440435 • Letter: A
Question
At Acme, they produce widgets. Widgets consist of two primary parts: a square whatsit, and a circular thingamabob. In order to make a valid widget, the whatsit must be able to fit inside a thingamabob, but without too much extra room. More specifically, the difference between the length of the diagonal of the whatsit and the length of the diameter of the thingamabob must be within 0.1 mm. The sensors provided to you at Acme can report the following two values: The length of a side on the square whatsit. The area of the circular thingamabob. Given these measurements, your program should produce a qualitative analysis on the compatibility between a given whatsit and thingamabob. Input Specification This program will receive a single line of input containing exactly two positive decimal values. The first value, s, denotes the length of a side on the square whatsit in mm. The second value, a, denotes the area of the circular thingamabob in mm squared. Output Specification Your program should print one of three lines, depending on the compatibility of the whatsit and thingamabob. If the difference between the length of the diagonal of the whatsit and the length of the diameter of the thingamabob are within 0.1 mm, output the following line: This whatsit and thingamabob will make a nice widget! If the length of the diagonal of the whatsit is more than 0.1 mm smaller than the diameter of the thingamabob, output the following line: This whatsit is too small, or this thingamabob is too big! If the length of the diagonal of the whatsit is more than 0.1 mm bigger than the diameter of the thingamabob, output the following line: This thingamabob is too small, or this whatsit is too big!Explanation / Answer
#include #include #define PI 3.1415926535898 int main() { double s,a;//s= length of sid on square watsit, a=area of circular thingamabob scanf("%lf %lf", &s, &a); double diagonal, diameter,difference; diagonal=sqrt(s*s*2); diameter=2*sqrt(a/ PI); difference=diagonal-diameter; if(difference==0.01)//not sure on this reasoning....since perfectsize (0) would be false here printf("This whatsit and thingamabob will make a nice widget! "); else if(difference < 0.01) printf("This whatsit is too small, or this thingamabob is too big! "); else //if(difference > .01); printf("This thingamabob is too small, or this whatsit is too big! "); return 0; }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.