Overview
This lab gives you practice with the following java functionalities:
- Use javax.Swing components for interaction with the user
- Use if, if-else, and switch statements for conditional execution
- Use DecimalFormat and printf for formatting output
LEGEND: Keyboard Screen
Task 0: Preliminary Tasks
- Review section 2.14 in the text on Dialog Boxes using JOptionPane.
- Read chapter 3
Task 1: ZanyLibs 2.0
- Create a new project in Eclipse named Chapter3.
- From within Eclipse, copy your ZanyLibs java file from Lab 2.1 into Chapter3.
- Update the header comment with a new version number (2.0), new version date, and new description (based on the changes described here).
- Modify your code to use JOptionPane rather than Scanner for user input.
- Use System.out to 'echo' user input; i.e., after a user enters the word "armadillo" in a dialog box, print a message to the Console window indicating the user input. For example, assume my program asks for two values entered via JOptionPane dialog boxes:
- Note: the "echo" response should be immediate -- one line of output after each step of user input.
- Caution: How can you get the double-quotes printed out in the console window?
The console window should now show the following:
User entered "Gene" for name. User entered "York" for city.
Task 2: ArabicToRoman 1.0
- Write a program that prompts the user to enter a number within the range of 1 through 10, using JOptionPane dialog boxes. Name your java class ArabicToRoman.
- User input via JOptionPane; should be echoed back to the console.
- User output via JOptionPane.
- Program should determine the Roman numeral equivalent, store it in a String variable, and then display it in a JOptionPane dialog box (and also print to the console window).
- Use if-then-if blocks to set the value of the variable holding the Roman numeral equivalent.
- If the user enters a number outside the range of 1-10, program should display an appropriate error message.
Task 3: BMICalculator 1.0
- Task 3 on page 175 of the text. Name your file BMICalculator
- Write a program that calculates and displays a person's body mass index (BMI).
- User input via JOptionPane; should be echoed back to the console.
- User output via JOptionPane.
- Final output should display all of the relevant values to the console window (System.out) (weight in pounds, height in inches, BMI, BMI range, and an appropriate message.
Task 4: DiscountSalesSummary 1.0
- Task 8 on page 176 of the text. Name your class DiscountSalesSummary.
- Write a program that asks the user how many copies of "BMI Calculator Deluxe" they would like to purchase.
- User input via JOptionPane.
- User output via System.out.
- Determine the discount based on the following table:
- 10-19 copies -- 20% discount
- 20-49 copies -- 30%
- 50-99 copies -- 40%
- 100 or more -- 50%
- Display a summary to the Console (System.out) showing
- number of copies ordered,
- price per copy,
- total cost,
- discount percentage,
- discount amount,
- final price.
- Sample output:
Sales Summary ------------- Copies ordered: 72 Price-per-copy: $99.0 Total cost: $7128.0 Congratulations! You are eligible for a 40% volume discount. Discount amount: $2851.2 Final price: $4276.8 Thank you for purchasing "BMI Calculator Deluxe!"


