The examination consists of two separate exercises. Marks will be divided equally between the two exercises.
The two exercises are related, but can be attempted independently (i.e. you do not have to complete the first in order to attempt the second, or vice versa). It is strongly recommended that you plan your allocation of time between the two exercises carefully in advance, and stick to this allocation during the exam.
When you have completed this exam, your report should be emailed to the address:
exam3b@ugmail.eeng.dcu.ie
Do not email multiple copies of the report. If you experience difficulties in emailing the report, please ask for help from an invigilator.
If a current I, in amperes, flows through a resistor of
resistance R, in , the power dissipated P,
in watts, will be given by the equation:
The program IPWR.C is supposed to prompt for and read in values for I and R, and then calculate and print out the corresponding power dissipation (P). It should do this repeatedly until a value of zero is entered for R, when it should terminate.
The program has various defects. You are required to correct all defects you can identify. For all changes that you make, the report should contain a clear statement of the change and a specific explanation of your rationale for the change. Of course, if you are making several similar or related changes, you may discuss these as a unit.
When you have reached the point where you think the program should work, then you should test it, and report on these tests. Carry out, and report on, further corrections if necessary.
Note carefully that you must not simply present a version of the program rewritten from scratch. You are required to identify the specific defects in the program you have been given.
Develop a program which will prompt for, and read in, a value for the resistance (R) of a resistor. Based on the equation provided in exercise 1, the program should then calculate, and output, a table showing the power which would be dissipated by this resistor for all currents between 0A and 1A inclusive, in steps of 100mA. Having completed printing this table, the program should then offer the user a choice between terminating, or repeating the calculation for a new resistor. The program should continue indefinitely (i.e. for as long as the user continues to request this).
You may develop this program from scratch, or, if you wish, you may reuse and augment your corrected program from Exercise 1. In either case, your program must conform to the following restrictions:
Test your program severely. Record all test results.