完成C语言基本作业,进行一些关于 Voltage
的基础的数值计算。
Requirement
Put your name and ID number in a comment at the top of your program.
Voltage readings are obtained from an electrical substation once every hour
for six hours (so there are six readings). Write a program to perform the
following checks on the substation:
- display all voltages that differ from the average by more than 10% of the average.
- display all pairs of consecutive hours where the change from the voltage at one hour to the next is greater than 15% of the average.
Example 1
Enter 6 voltages: 210.1 223.2 189.6 206.2 235.1 215.0
The average is 213.2 volts.
10% = 21.3 volts.
15% = 32 volts. [optional - you could display this as 32.0 volts if you prefer]
The following problems occurred:
- Voltage at hour 3 was 189.6 volts (difference of 23.6 volts).
- Voltage at hour 5 was 235.1 volts (difference of 21.9 volts).
- Voltage change from hour 2 to hour 3 was 33.6 volts.
Example 2
Enter 6 voltages: 233.1 201.0 221.5 240.2 222.7 208.1
The average is 221.1 volts.
10% = 22.1 volts.
15% = 33.2 volts.
No problems were encountered.
Notes
Each problem in Example 1 has its own line number. display numbers with no
decimal places or 1 decimal place (but not more than 1). any problems of the
first type are reported before any problems of the second type. the output in
Example 2 must be used if no problems occurred. make sure that the problem
heading is displayed even if there are only problems of the second type.
voltage differences must be displayed as positive values - do not display any
negative values. section 6 of the notes (functions) is optional for this
assignment - you do not have to make use of functions but you can include
functions if you would like to do s.