Description
Objectives
- Work with JOptionPane dialog boxes.
- Parse data from a JOptionPane input box.
- Compute the average of three floating point values.
- Print output to the screen.
Motivation
This is a variation on problem number 10 on page 107 in the textbook. Your task is to prompt the user for three test scores. You should then compute the average of the test scores and display the average. The difference between the book’s description and this assignment is that I would like for you to use JOptionPane dialog boxes.
This will also require that you parse a String object into a floating point type. You should be using the double type for test scores and averages. As a reminder, the JOptionPane will only return values as String objects. The slides on the course website and Chapter 2 of the textbook will have example code on how to parse String objects into other types.
Instructions
Name your project FirstnameLastnameAssignment5
Have your program do the following.
- Display a JOptionPane.showMessageDialog which says that this program will average three test scores.
- “Welcome to Dr. Church’s Test Score Averaging Software”
- Prompt the user for three test scores using JOptionPane.showInputDialog. These must be stored into String objects. The dialog boxes should be numbered appropriately. For example, the first test score prompt should say “Enter Test Score 1:”.
- For each test score String object, convert that test score into a double
- Compute the average test score by adding up each of the scores and dividing by 3. Store this into a new (and appropriately named) variable.
- Using a JOptionPane.showMessageDialog, display the average of the three test scores. Make sure that the dialog box says something to the effect of “Your average score is ” and then mention the score.
Notes:
- This program will not use the Scanner class or print anything to the Console via out.
- All of your variables should be appropriately named.
- Do not make calculations inside of statements which display information. Always store calculations to variables, then display those variables.
Your source code must include the following documentation:
- Your name
- The class (CS 2070) and the section number (on ground is 08, online is W1).
- The date on which you turned in the assignment.
- A short description of the software. Usually a sentence or two is sufficient.
Example Run
Not yet, but this should be enough to go on.
Turning it in.
To turn in your application, find the folder containing your entire project (not the folder with the “java” file), zip it up, and turn it in.