Unit 3 Program

Please, you get to make a choice - look at all of them before you start. Only one program is required
Do not ask for help. This is an evaluation of what you know. They will be graded only once. -5 points if I have to regrade it.

Exceptions: If you have lots of time, do the program for 100 points, get it graded, then go on and try the dice program. I will regrade it for the higher grade.

VERY EASY - 75 or 80 pts

Open Lab3d4, save as U3p1

1. Add a JButton and a JTextField at the end.
2. Add int a = 0; to the variable declaration section
3. Inside the ActionPerformed ( 5 times) there is a place where you say the answer is correct.
    Add this a = a+1;

4. Add the conditional for the 6th JButton inside the actionPerformed and
       print out the number correct (the purpose for the variable a) in the JTextField.

Here are some pictures of what it would look like.

You may change the size of the window as needed. If you use at least 2 fonts and 2 custom colors, and make it look nice, the grade will be 80.


More difficult

There are 2 versions for this one. Open Lab3b3 and save as U3p2

This is worth 95 pts if it works correctly and has fonts and custom colors. Read the notes below

 

1. Add a JButton that says submit and a JTextField for the score.

2. In the ActionPerformed method, there can only be one getSource.

You must get the 4 JTextFields into 4 different Strings ( unlike Lab4d4 which had 5 JButtons - therefore it had 5 getSources and could use the same String over and over again.)

3. You will have to check each of the Strings with an if (I did not use an else because I did nothing if the answer was wrong).

I let the color change indicate that it was correct. You can do it differently and tell the correct answer on wrong ones if you want to.

4. Add int a = 0; to the variable declaration section. Inside the ActionPerformed, inside the getSource conditional, there is a place where you say the answer is correct( 4 times).   Add this a = a+1; to count the answer as correct.

5. Add a setText for the JTextfield to print out your score.

This is worth 100 pts if it works correctly and has fonts and custom colors. Read the notes below.

1. Add a JButton that says submit and a JTextField for the score and a JButton for reset.

2. In the ActionPerformed method, there must be two getSources.

In one of them, You must get the 4 JTextFields into 4 different Strings ( unlike Lab4d4 which had 5 JButtons - therefore it had 5 getSources and could use the same String over and over again.)

3. You will have to check each of the Strings with an if - (I did not use an else because I did nothing if the answer was wrong). I let the color change indicate that it was correct. You can do it differently and tell the correct answer on wrong ones if you want to.

4. Add int a = 0; to the variable declaration section. Inside the ActionPerformed, inside the getSource conditional, there is a place where you say the answer is correct( 4 times).   Add this a = a+1; to count the answer as correct.

5. Add a setText for the JTextfield to print out your score.

6. The reset JButton will empty out all the JTextfields, restore any original colors and reset a back to zero. In my sample the reset JButton is turned off until the "submit" JButton is clicked - That was a personal choice, you do not have to have it that way.