Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
-1 of 2- 
The University of New Mexico 
CS 152: Computer Programming Fundamentals in Java 
 
 
 
Lab 3:  
Roach Population  
Overview: 
You will be modifying and expanding the Roach Population Program, Listing 4.3 of 
the textbook.  
1) Listing 4.3 is a console application getting its input using 
java.util.Scanner and showing its output using System.out.println.  
Your program must use the static methods of the 
javax.swing.JOptionPane class to receive input and to display output. 
2) Listing 4.3 will crash if the user enters bad input. Your program must do a 
better job of handling bad input. When the user enters bad input: 
a) Display an error message indicating what the error was in 
JOptionPane.showMessageDialog with type = ERROR_MESSAGE. 
b) After the user closes the error message dialog, loop back to the 
offing input question and ask it again. 
c) Exit the program if the user clicks "cancel" on any of the input 
dialogs. 
 
Grading Rubric [20 points total]: 
1) [1 point]: Attached one file in WebCT with the file name: RoachPop.java. 
2) [5 points]: When given valid input, your program produces the same output 
results as does Listing 4.3 with the exception that your program's output is 
displayed in a JOptionPane.showMessageDialog and your input is read 
from a JOptionPane.showInputDialog.  
3) [2 points]: When the user clicks "cancel" on an input dialog, your program 
exits. 
-2 of 2- 
4) When the user enters invalid input, your program must display an error dialog 
that indicates what type of error the user made. Your program must 
correctly identify each of the following types of errors: 
a) [3 points]: The house volume must be a positive floating point number 
greater than 0.0 and less than the volume of Boeing Everett Factory in 
Washington (472,370,319 cubic feet). 
b) [3 points]: The estimated number of roaches in your house must be a 
positive integer greater than 0 and no larger than the number that would 
fit in your house. 
5) [6 points]: After the user closes an error dialog, your program must display 
the same input dialog as in step 2 above and respond either with the correct 
output as in step 2 or display another error dialog - depending on the validity 
of the new input. 
 
 
Penalties: 
[-5 points]: Code does not adhere to the hallowed CS-152 coding standard: 
http://www.cs.unm.edu/~joel/cs152/CS-152-Lecture-05-CodeStandards.pdf. 
This includes indenting, class, method, and in-line comments, removing all 
warnings, etc. Note: all 5 points are lost if any one of the standards is 
severely broken. For example: 
● Very Poor comments: -5.  
● Poor comments: -1 through -3. 
● Many indenting errors: -5.  
● A few indenting errors: -1 through -3. 
● Multiple breaking of naming convention: -5. 
● Multiple warnings (other than the ignorable: Serializable class does not 
declare static version number).