Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program which accomplishes the following requirements: 1. On execution, the program must display the name (describing the main functionality) of the program
Write a program which accomplishes the following requirements: 1. On execution, the program must display the name (describing the main functionality) of the program and ask the user for the input file name and output file name. If the input file does not exist, print an error message and ask the user for the file name again. The program output (to the screen) during the user input stage should look like the following snapshot: CENTROIDAL MOI CALCULATOR INPUT: Please enter input file name: input.xt ERROR: Input file not exist... Please re-enter input file name: input.txt Please enter output file name: output.txt 2. The input file to the program contains a single line header that describes the column names, followed by the input specification (type and radius) for each case in the form of where is specified as a single character, whereas is specified as numeric values. Example input program is shown below (with error in types and values included): ...ments/teaching-2021202202/5c/project_c/input.txt - KWrite File Edit View Bookmarks Tools Settings Help Open... Save As... Type Radius A 0.3 New 1 2 3 B 1 4567BSOL 0.1 A 3.20E+01 A 1.60E+04 B0 8 B-2 C 3 10 D 5 11 | Save Close 3. Calculation of moment of inertia for different shapes must be implemented inside their respective functions. The error must be indicated if the shape type is not in the given list in Table 1 and/or a zero and negative value for radius is given. 4. Output of the program should be both printed on the screen and written to the named output file, in the form of with a corresponding single line header. The error must be indicated for specific cases in the output. For the above input, the content of the output file should look like the following snapshot: ...ents/teaching-2021202202/SE.../project_c/output.txt KWrite File Edit View Bookmarks Tools Settings Help Save As... New Open... Save Type Radius MOIX MOIY A 3.000e-01 6.363e-03 6.363e-03 B 1.000e+00 1.898e-01 3.927e-01 C 1.000e-01 5.492e-06 3.928e-05 A 3.200e+01 8.237e+05 8.237e+05 A 1.600e+04 5.148e+16 5.148+16 B 0.000e+00 "INPUT_ERROR" B -2.000e+00 "INPUT_ERROR" C 3.000e+00 4.449e+00 3.181e+01 D 5.000e+00 "INPUT_ERROR" e 8 of 11, Column 16, Words (V82, Chars 0/2 INSERT Clase + Tabs: 2 v TF V n 5. You need to generously describe your code via comments (either use /* ) */ or // The overall program execution should look like the following snapshot: project_c: cb_console_runn - Konsole File Edit View Bookmarks Settings Help CENTROIDAL MOI CALCULATOR INPUT: Please enter input file name: input.xt ERROR: Input file not exist... Please re-enter input file name: input.txt Please enter output file name: output.txt OUTPUT: Type Radius MOIX MOIY A 3.000e-01 6.363e-03 6.363e-03 B 1.000e+00 1.098e-01 3.927e-01 C 1.000e-01 5.492e-06 3.928e-05 A 3.200e+01 8.237e+05 8.237e+05 A 1.600e+04 5.148e+16 5.148e+16 B 0.000e+00 "INPUT ERROR" B -2.000e+00 "INPUT_ERROR" C 3.000e+00 4.449e+00 3.181e+01 D 5.000e+00 "INPUT_ERROR" Process returned 0 (0x0) Press ENTER to continue. execution time: 25.714 s input.txt 11-21222 Programming for Engineers Section 11 Type Radius A 0.3 B 1 C 0.1 A 3.20E+01 A 1.60E+04 B0 B-2 C 3 D 5 input_for_win.txt22 Programming for Enginee Section Type Radius A 0.3 B 1 C 0.1 A 3.20E+01 A 1.60E+04 B-2 C 3 D 5 Formulas to calculate the moment of inertia about the centroid of 3 different circle-based shapes are given below. Table 1: Selected formulas to calculate moment of inertia for different shapes Type Shape MOI about centroidal x' axis MOI about centroidal y' axis 4 = 3 A B () 9 0 TAI T3L 8 4 = (-2)* 4 = (-2)* 3 11
Step by Step Solution
There are 3 Steps involved in it
Step: 1
To create a program that fulfills the requirements shown in the images you need to follow these step...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