CS 280 Spring 2009           Assignment 8 – Looping, Nested Loop and Reading from Files                            100 “Assignment” points

 

Assigned: 03/26/2009

Due: 04/02/2009 at the start of class  (after break)

 

Pre-Lab (Do Before Lab):  Bring materials – a USB for a take home copy. If you have a chance, plan out your GUI, tasks, objects, and events needed for program. Plan out how you will solve the problem. There is at least one part of this assignment that will take some thought!

 

Main Assignment:

Imagine you are writing a simplified program to help State U explore what their application pool looks like. Since State U receives enormous numbers of applications, they do not have time to read essays and will only look at SATs and high school GPA.  We are still a bit away from being able to do the full job, so pay attention to what I’m asking for. Also note that you will need to gain an understanding of the provided Applicant class. The provided class will be in a zip file on Blackboard, along with documentation for the class.  A quick introduction is included below. You will need to

·         declare an ArrayList object as an instance variable in your GUI class so that it is available from all of your buttons (and from start up code). You should also instantiate it as an empty ArrayList when you create it.

·         Write a method (general in your GUI class) to read info from a file, creating Applicant objects and adding them to the ArrayList. Please see hints and details below.

·         Call that method upon start up (after GUI components are initialized), so no buttons have to be clicked in order for applicant information to be available.

You should create buttons in your GUI to:

·          Determine how many applicants meet a given total SAT threshold (that score or higher). Get the given threshold from the user via a text field.

·         Determine how many applicants meet a given high school GPA threshold (that GPA or higher). Get the given threshold from the user via a text field.

·         Determine how many applicants meet both a given total SAT and a given high school GPA threshold (given values or higher). Get the given thresholds from the user via text fields.

·         Determine how high a target Math SAT score has to be in order to get the percent of applicants below a given threshold (entered as a decimal please! – i.e. 20% is expressed as 0.20). Get the given percent threshold from the user via a text field.

·         Quit

 

Background Knowledge:

 

User Interface:

·         You’re just a beginning at setting up GUIs in NetBeans. Don’t worry too much about making the interface nice.  See my simple sample interface below – Don’t let that constrain your creativity. I know that mine can be improved upon!!! Use it to help understand what I see as inputs and outputs. The version of the assignment on my www site includes more pictures (“screen shots”). The version on Blackboard may not include any.

·         If you prefer to display answers in the form itself instead of using message boxes, feel free to do so.

·         Format outputs of GPAs and percents to have reasonable number of decimal places. Let’s avoid using real percents in favor of decimal equivalents (saves a little bit of effort) 

·         Include your name in a label or the title bar on your GUI form  

 

Miscellaneous Details:

 

Good Programming Practices:

o    MAKE SURE YOUR PROGRAM WORKS! (i.e. gets correct results).  It must provide all of the requested capabilities AND provide them in the expected way.   

o    We are now branching – so the program must be tested on more inputs to ensure that all paths through the program code work!     

·         Add YOUR NAME, e-mail address, and purpose of the program in comments at the beginning of your file (the date should already be there – which is also a very good practice). The purpose should be what the program is supposed to do, not the learning goals.

·         Name all variables and constants meaningfully.

·         Name meaningfully all jbuttons, jtxtfields, jlabels, etc that will be referred to in code. Use conventions for the start of their names.

·         If you provide any outputs on the form itself, make the results read-only. (not editable)

·         Define numbers (especially those that could change sometime in the future) as named constants (i.e. they should be ‘final’). You can use public constants from the Applicant class via the class name (e.g. Applicant.MAX_GPA)

·         Only variables that need to be accessed from more than one button  should be declared as instance variables for the GUI class. Others should be declared local to the methods they are used in.

·         Indent to show any structure of the program (The IDE usually does this well if you don’t go back and change things – probably not much to worry about on this basic of a program)

o    You MUST include some comments that explain your program in order to get full credit; any complexity should have comments – if you had to stop and think about how to do something, it needs a comment.

 

Red Tape to Aid Grading:

·         Please set the name of the project to something other than the default name (JavaApplication1, …). 

·         Add  your name in a jlabel on the GUI form or on the title bar.

 

Hand in:

 

Do your own assignments !!!!  Work that is copied or done with somebody (when not assigned to a group) will be punished. If programs are copied, both students will receive a zero for the assignment. If significant sections of programs are copied, points will be taken off. Changing small aspects of a copied program does not make it not a copy. Asking another for help on a step or two in a many-step assignment is acceptable; looking at another person’s program is temptation for cheating; handing in a near duplicate program is cheating


Sample Interface:

 

On Startup if data file isn’t found:

 

 

On Startup:

 

 

Invalid Total SAT Threshold entered:

 

 


Invalid GPA Threshold Entered:

 

 

Ready to do valid qualification search:

 

 

SAT search results:

 

 

GPA search results:

 

 

Both Search Results:

 

 

Invalid Percent Threshold Entered:

 

 

Ready to do valid percent threshold search:

 

 

Percent threshold Search Results (interpretation – in order to get down below 20% accepted, would need to get SAT threshold up to 630):