Home /
Expert Answers /
Civil Engineering /
problem-statement-formulas-to-calculate-the-moment-of-inertia-about-the-centroid-of-3-different-ci-pa701
(Solved):
Problem statement Formulas to calculate the moment of inertia about the centroid of 3 different ci ...
Problem statement 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 MOI about centroidal x' axis centroidal y' axis A 1 3² 4 = ( ? 3 ) ²² 4 = ( ? 2 ),* - B C 7 0 0 y C. ? X 1 3²² || ||
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 New Open... Save Save As... Close Type Radius A 0.3 ? 0.1 A 3.20E+01 A 1.60E+04 B0 8 B-2 C 3 10 D 5 11 | 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. 1 2 3 B 1 4567BSOL
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
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 New Open... Save Save As... Clase 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 (B2, Chars 0/2 INSERT + Tabs: 2 v TF V n 5. You need to generously describe your code via comments (either use /* */ or // )
Final Code: Result: Code in text : import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.*; public class chegg2 { public static double calMoiX(char type,double r) { //function to calculate moment of inerti