48.5k views
4 votes
Where am I supposed to put the paramas.txt file for it to be found is that even what the issues is. The code and the errors are both in the screen shot. The instructions to the code are listed in bold below

P11.12 After the switch in the figure below closes, (see book for figure), the voltage (in volts) across
the capacitor is represented by the equation
v(t) = B(1 - e-t/(RC))
Suppose the parameters of the electric circuit are B = 12 volts, R = 500 , and C = 0.25 F.
Consequently
v(t) = 12(1 – e-0.008t)
where t has units of s. Read a file params.txt containing the values for B, R, C, and the starting
and ending values for t. Write a file rc.txt of values for the time t and the corresponding capacitor
voltage v(t), where t goes from the given starting value to the given ending value in 100 steps. In our
example, if t goes from 0 to 1000 s, the twelfth entry in the output file would be:
110.00 7.02261
Make sure that your program catches the FileNotFoundException that can occur if your input
file params.txt cannot be found. Your program should catch this exception, and then prompt the
user for a file name again until a valid file is entered.
IMPORTANT!! For this lab you simply need to create a CapacitorVoltage class that
implements the main method in order to perform your file I/O. Make sure you use params.txt as
your input file. Use rc.txt for your output file

User Bav
by
7.6k points

1 Answer

4 votes

Final answer:

The student's task involves coding a class that reads parameters from a 'params.txt' file and calculates the voltage across a capacitor over time in an RC circuit, outputting the results to 'rc.txt'. They must also handle file I/O exceptions.

Step-by-step explanation:

The student in this question is tasked with creating a CapacitorVoltage class that writes to an output file rc.txt based on the parameters read from an input file params.txt. The params.txt file must include values for the parameters B (voltage in volts), R (resistance in ohms), and C (capacitance in farads), as well as the starting and ending values for time t. The question deals with the equation V = emf(1 - e-t/RC) which describes the voltage across a capacitor over time when it is being charged in an RC circuit. The student is required to handle a possible FileNotFoundException in their code by prompting the user for a valid file name when needed.

User Sal Aldana
by
7.5k points