Home /
Expert Answers /
Computer Science /
use-c-and-create-a-flowchart-too-cls-217-exercise-2-4-creating-a-switch-statement-with-a-pa375
(Solved): USE C++ and create a flowchart too
ClS 217 Exercise \( 2.4 \) Creating a switch statement with a ...
USE C++ and create a flowchart too
ClS 217 Exercise \( 2.4 \) Creating a switch statement with a range for each case In this exercise you will use a solar energy equation to calculate expected solar panel power relative to actual measured solar power for an array of solar panels. Then compare the two values as a relative efficiency. The relative efficiency will be used to detect the functional state of the solar array and be used as a parameter for a switch statement to display the message for each functional state. All the values are floating point except for the relative efficiency which must be an integer to work properly in the switch statement. power_max \( =( \) rated_efficiency \( / 100) \) * sun_energy * panel_area t_derate_factor \( =1 \)-(temperature \( -25.0) / 200.0 \) power_derated= power_max*t_derate_factor relative_efficiency \( = \) power_measured /power_derated \( * 100+0.5 \) note: rated_efficiency, sun_energy, panel_area, temperature, and power_measured are user inputs if relative_efficiency is greater than 100 , set relative_efficiency equal to 100 (NOTE THIS IF STATEMENT ALSO MUST BE PLACED DIRECTLY ABOVE THE SWITCH STATEMENT AS SHOWN BELOW) Below is example puesdo code (using if statements) showing what the switch operation must be made to perform(note each the if statements is true for a range of relative_efficiency) : if (relative_efficiency \( >90 \) ) print "the panels are functioning optimally" else if (relative_efficiency \( >80 \) ) print "inspect the panels for dust" else if (relative_efficiency \( >70 \) ) print " the panels are most likely filthy " else if (relative_efficiency \( >50 \) ) print " the panels may be partially obstructed" else if (relative_efficiency \( >30 \) ) print " the panels nearly mostly obstructed" else print "the panels may have failed " Convert the if statement code above to a switch statement that calculates the same results. The switch has the below format using range notation (case begin ... end): Switch ( variable_xyz) //note variable_xyz in this case is integer relative efficiency \{ case \( 70 . .79: / / \) this is showing a potential range of values you will have to change the numbers printf("the first message"); break; case 50 ... 69: printf("the second message "); break; default: printf("the last message "); \} See the screen shots on the next sheet for user input values to compare with
Maximum Panel Power 20000. W? Watts Temperature Derated Panel Power 19000.00 Watts Relative Panel Efficiency \( 89 \% \) inspect the panels for dust Enter the rated solar panel efficiency in \( \%> \) Decreasing the measured power made the relative efficiency go down This program detects the state of a solar array Enter the rated solar panel efficiency in \( \%>20 \) Enter the sun radiation energy in watts \( / \mathrm{m}^{\wedge} 2>1000 \) Enter the solar panel area in \( m^{\wedge} 2>100 \) Enter the solar panel temperature in deg \( C>45 \) Enter the measured solar panel power in Watts>17??] Maximum Panel Power 20000.0? Watts Temperature Derated Panel Power 18000.00 Watts Relative Panel Efficiency \( 94 \% \) the panels are functioning optimally Enter the rated solar panel efficiency in \( \%> \) Notice as temperature goes up the panel is less efficient; however the measured power stayed the same in this example so the relative efficiency went back up some. Calculate values as displayed and the ones needed to make the rest of the messages display and generate a screen shot of all 6 messages in your results You can use goto TOP and a label at the TOP: to recalculate your outputs for various inputs.