CS 1400 Fundamentals of Programming

Project 11: Testing Power Ratings

Objective:

This project will test your ability to write a program that

  1. Uses a Console Interface
  2. Uses a Domain class of your design
  3. Uses an array of values
  4. Uses Methods
  5. Opens a file and reads data from a file
  6. Uses loops and decision logic.

Background

logo

The ability of a resistor in an electrical circuit to reduce the flow of electricity through the circuit is measured in ohms. The voltage drop across a resistor is measured in volts. The power dissipated by the resistor is measured in watts. Using Ohm's Law we can derive the equation for finding the power dissipated by a resistor. It is equal to the square of the voltage drop across the resistor divided by the resistance of the resistor, or

P = v2/R,

where P is the power dissipation of the resistor, v is the voltage drop across the resistor, and R is the resistance of the resistor.

Program Overview

When you buy a resistor, it will have a specified resistance value and a specified maximum power rating. Suppose that you work for a large electronics firm, and you have been asked to create a program to aid in testing batches of resistors. When the resistors are manufactured, each resistor in the batch should have the same resistance, and the power dissipation of every resistor in the batch must be greater than or equal to the maximum power rating. To test the manufacturing process a random batch of resistors is collected and the voltage across each resistor in the batch is measured. The data from this collection is stored in a file. The objective of your program is to read the data from the file and see if the power dissipation of any of the resistors in the batch is lower than the maximum power rating specified for this resistor. If the power dissipation of any single resistor in the batch is lower than the maximum power rating, your program must alert the user to this fact.

Program Design

Your program should work as follows:

  1. This is a console program. All of the data and the methods that deal with a test batch of resistors must be placed in a domain class of your design.
  2. The program will ask the user for a file name. Your program will assume that the file is in the user's Documents folder.
  3. The program will open the file. Your program should assume that the file is there and that it opened correctly. No code is required to handle the error case where the file does not open.
  4. Your program will then read a line of data from the file that contains a value for the specified resistance for this batch of resistors followed by the maximum power rating.
  5. Your program will then read from the file a series of voltages for this batch of resistors. Each voltage value is on a separate line in the file. You do not know how many voltages are in the file, so you will have to read data until you reach the end of the file. These voltage values should be stored in an object of your domain class, in an array of doubles. Make the array big enough to hold 50 voltages. There may be fewer than 50 voltages in the file, but there will never be more than 50.
  6. After reading all of the data from the file, you program will display a table as shown in the example output below. The table lists each resistor, the power dissipation for that resistor, and whether or not it passed the test. If the power dissipation of any resistor is less than the maximum power rating for this batch of resistors, the resistor fails the test.

Sample Data File

There is a sample data file here. Your program should work with this data file.

Sample Executable

There is a sample executable file here.

File(s) to Submit:

Place your complete project folder into a zip file and name the zip file
proj_11_your-initials_V1.0.zip. For example, I would name my file proj_11_RKD_V1.0.zip. Submit this assignment as Project #11 on Canvas.

Grading Criteria

Description Points possible Your points

Project meets the following guidelines:
o Source code files contain a declaration that you did not copy any code
o Project has been submitted to Canvas
o Code meets style guidelines
o Code is properly documented.

5  

Your program asks the user for a file name. The file is assumed to be in the user's Documents folder. Once the file opens, your program successfully reads all of the data from the file, as described above.

5  

Your program calculates the power dissipation for each resistor and displays these values in a table, along with an indication of whether or not the resistor passed the test.

5  

The data and the methods dealing with a test batch of resistors is properly encapsulated in a domain class of your design.

5  

Early Bonus (+3 pts) or late penalty(-20% per day)

  

Total

20