|
From: SourceForge.net <no...@so...> - 2008-02-14 20:48:08
|
Bugs item #1894022, was opened at 2008-02-14 12:48 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=438935&aid=1894022&group_id=44253 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: 4: Serious Status: Open Resolution: None Priority: 5 Private: No Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: Code causes DrJava to freeze Initial Comment: The code listed below, when run several times in a row, appears to cause DrJava to hang. I've included the error information after the code. import java.util.Scanner; /** * This class processes a series of music rentals. The program uses * a while loop to allow the user to enter music rentals until * the user enters "quit" for a user name. * @author Heidi J. C. Ellis * Created: 02-07-08 */ public class MusicRentals { public static void main(String[] args) { // Declare variables for customer name, id, rental plan // additional songs rented per month, and charge. String customerName = ""; String customerID; char rentalPlan; int numberOfSongs; double charge =0; int numberOfCustomers = 0; // Number of customers double totalCharges = 0.0; // Total charges for all renters // Declare a Scanner to allow keyboard input from standard in. Scanner input = new Scanner(System.in); // Declare constants for basic rental charge plans final double PREMIUM_DISCOUNT = 0.05; final double PLAN_A = 5.00, PLAN_B = 10.00, PLAN_C = 15.00; final double PLAN_A_OVER = 0.20, PLAN_B_OVER = 0.10; final int PLAN_A_SONG_MAX = 100, PLAN_B_SONG_MAX = 200; System.out.println("Welcome to Rockin\' Rental!"); System.out.print("Enter customer name (enter \"exit\" to exit): "); customerName = input.nextLine(); while (!customerName.equals("exit")) { // Prompt the customer for account information System.out.print("Enter customer ID: "); customerID = input.nextLine(); System.out.print("Enter rate plan: "); rentalPlan = input.nextLine().toUpperCase().charAt(0); System.out.print("Enter number of songs rented: " ); numberOfSongs = input.nextInt(); if (rentalPlan == 'A') { charge = PLAN_A; if (numberOfSongs > PLAN_A_SONG_MAX) { charge = charge + ((numberOfSongs-PLAN_A_SONG_MAX)*PLAN_A_OVER); } } else if (rentalPlan == 'B') { charge = PLAN_B; if (numberOfSongs > PLAN_B_SONG_MAX) { charge = charge + ((numberOfSongs-PLAN_B_SONG_MAX)*PLAN_B_OVER); } } else if (rentalPlan == 'C') { charge = PLAN_C; } else { System.out.println("Invalid plan."); } // If the customer is a premium member, then give the premium discount if (customerID.toUpperCase().charAt(0) == 'P') { charge = charge - (charge * PREMIUM_DISCOUNT); } // If customer is not a premium member and has rented more than // 1000 songs, suggest that they become a premium member. if ((numberOfSongs > 1000) && (customerID.toUpperCase().charAt(0) != 'P')) { System.out.println("You have rented over 1000 songs this month and "+ "you are not a premium member.\n You should consider " + "becoming a premium member. You would save $" + (charge * PREMIUM_DISCOUNT)); } // Increment the number of customers and add the current // charge to the total charge. numberOfCustomers++; totalCharges = totalCharges + charge; // Output customer information System.out.println("Customer name: " + customerName); System.out.println("Customer ID: " + customerID); System.out.println("Customer rate plan: " + rentalPlan); System.out.println("Number of songs rented: " + numberOfSongs); System.out.println("Charge: $" + charge); // "Read" the trailing end of line character. customerName = input.nextLine(); System.out.print("Enter customer name (enter \"exit\" to exit): "); customerName = input.nextLine(); } // End the while loop // Output the total number of customers and the average charge System.out.println(); System.out.println("Total number of customers: " + numberOfCustomers); System.out.println("Average charge: $" + (totalCharges/numberOfCustomers)); } } java.lang.ArrayIndexOutOfBoundsException at java.lang.System.arraycopy(Native Method) at javax.swing.text.CompositeView.replace(Unknown Source) at javax.swing.text.BoxView.replace(Unknown Source) at javax.swing.text.View.updateChildren(Unknown Source) at javax.swing.text.View.insertUpdate(Unknown Source) at javax.swing.plaf.basic.BasicTextUI$RootView.insertUpdate(Unknown Source) at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.insertUpdate(Unknown Source) at javax.swing.text.AbstractDocument.fireInsertUpdate(Unknown Source) at javax.swing.text.AbstractDocument.handleInsertString(Unknown Source) at javax.swing.text.AbstractDocument.insertString(Unknown Source) at edu.rice.cs.util.text.SwingDocument.forceInsertText(SwingDocument.java:138) at edu.rice.cs.util.text.ConsoleDocument.insertBeforeLastPrompt(ConsoleDocument.java:223) at edu.rice.cs.drjava.model.repl.InteractionsModel.interpreterResetting(InteractionsModel.java:540) at edu.rice.cs.drjava.model.repl.newjvm.MainJVM.killInterpreter(MainJVM.java:565) at edu.rice.cs.drjava.model.repl.RMIInteractionsModel._resetInterpreter(RMIInteractionsModel.java:104) at edu.rice.cs.drjava.model.repl.InteractionsModel.resetInterpreter(InteractionsModel.java:204) at edu.rice.cs.drjava.model.DefaultGlobalModel.resetInteractions(DefaultGlobalModel.java:335) at edu.rice.cs.drjava.model.DefaultGlobalModel.resetInteractions(DefaultGlobalModel.java:311) at edu.rice.cs.drjava.model.DefaultGlobalModel$2.compileEnded(DefaultGlobalModel.java:165) at edu.rice.cs.drjava.model.compiler.CompilerEventNotifier.compileEnded(CompilerEventNotifier.java:86) at edu.rice.cs.drjava.model.compiler.DefaultCompilerModel._doCompile(DefaultCompilerModel.java:245) at edu.rice.cs.drjava.model.compiler.DefaultCompilerModel.compileAll(DefaultCompilerModel.java:139) at edu.rice.cs.drjava.ui.MainFrame._compileAll(MainFrame.java:4209) at edu.rice.cs.drjava.ui.MainFrame.access$4100(MainFrame.java:106) at edu.rice.cs.drjava.ui.MainFrame$44.actionPerformed(MainFrame.java:680) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) System Properties: DrJava Version 20070130-2255 java.runtime.name = Java(TM) SE Runtime Environment sun.boot.library.path = C:\Program Files\Java\jre1.6.0_04\bin java.vm.version = 10.0-b19 java.vm.vendor = Sun Microsystems Inc. java.vendor.url = http://java.sun.com/ path.separator = ; java.vm.name = Java HotSpot(TM) Client VM file.encoding.pkg = sun.io sun.java.launcher = SUN_STANDARD user.country = US sun.os.patch.level = Service Pack 2 java.vm.specification.name = Java Virtual Machine Specification user.dir = <anonymized user.home>\Desktop java.runtime.version = 1.6.0_04-b12 java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment java.endorsed.dirs = C:\Program Files\Java\jre1.6.0_04\lib\endorsed os.arch = x86 java.io.tmpdir = C:\DOCUME~1\<anonymized user.name>\LOCALS~1\Temp\ line.separator = "\u000d\u000a" java.vm.specification.vendor = Sun Microsystems Inc. user.variant = os.name = Windows XP sun.jnu.encoding = Cp1252 java.library.path = C:\Program Files\Java\jre1.6.0_04\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Adaptec Shared\System;C:\Program Files\MySQL\MySQL Server 4.1\bin; C:\Program Files\Java\jdk1.5.0_04\bin;C:\Program Files\QuickTime\QTSystem\ java.specification.name = Java Platform API Specification java.class.version = 50.0 sun.management.compiler = HotSpot Client Compiler os.version = 5.1 user.home = <anonymized user.home> user.timezone = America/New_York java.awt.printerjob = sun.awt.windows.WPrinterJob file.encoding = Cp1252 java.specification.version = 1.6 java.class.path = <anonymized user.home>\Desktop\drjava-stable-20070130-2255.jar;C:\Program Files\Java\jdk1.6.0_04\lib\tools.jar;C:\Program Files\Java\jdk1.6.0_02\lib\tools.jar user.name = <anonymized user.name> java.vm.specification.version = 1.0 java.home = C:\Program Files\Java\jre1.6.0_04 sun.arch.data.model = 32 user.language = en java.specification.vendor = Sun Microsystems Inc. awt.toolkit = sun.awt.windows.WToolkit java.vm.info = mixed mode, sharing java.version = 1.6.0_04 java.ext.dirs = C:\Program Files\Java\jre1.6.0_04\lib\ext;C:\WINDOWS\Sun\Java\lib\ext sun.boot.class.path = C:\Program Files\Java\jre1.6.0_04\lib\resources.jar;C:\Program Files\Java\jre1.6.0_04\lib\rt.jar;C:\Program Files\Java\jre1.6.0_04\lib\sunrsasign.jar;C:\Program Files\Java\jre1.6.0_04\lib\jsse.jar;C:\Program Files\Java\jre1.6.0_04\lib\jce.jar;C:\Program Files\Java\jre1.6.0_04\lib\charsets.jar;C:\Program Files\Java\jre1.6.0_04\classes java.vendor = Sun Microsystems Inc. file.separator = \ java.vendor.url.bug = http://java.sun.com/cgi-bin/bugreport.cgi sun.io.unicode.encoding = UnicodeLittle sun.cpu.endian = little java.rmi.server.hostname = 127.0.0.1 sun.desktop = windows sun.awt.exception.handler = edu.rice.cs.drjava.ui.DrJavaErrorHandler sun.cpu.isalist = pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86 #DrJava configuration file #Thu Feb 14 15:44:59 EST 2008 javac.location = C:\\Program Files\\Java\\jdk1.6.0_04\\lib\\tools.jar extra.classpath = C:\\Documents and Settings\\<anonymized user.name>\\My Documents\\Courses\\Introduction to Computing\\Code\\objectdraw.jar;C:\\Documents and Settings\\<anonymized user.name>\\My Documents\\Alice\\Java\\intro-prog-java\\bookClasses font.main = Monospaced-24 font.line.numbers = Monospaced-24 font.doclist = Monospaced-16 font.toolbar = -14-12 lineenum.enabled = true key.delete.next = shift DELETE key.delete.previous = shift BACK_SPACE quit.prompt = false save.before.compile = true recent.files = [C:\\Documents and Settings\\<anonymized user.name>\\My Documents\\Courses\\Introduction to Computing\\Spring 2008\\Labs\\Lab4\\MusicRentals.java,C:\\Documents and Settings\\<anonymized user.name>\\My Documents\\Courses\\Introduction to Computing\\Spring 2008\\Labs\\Lab3\\MusicRental.java,C:\\Documents and Settings\\<anonymized user.name>\\My Documents\\Courses\\Introduction to Computing\\Spring 2008\\Quizzes\\IfTest.java,C:\\Documents and Settings\\<anonymized user.name>\\My Documents\\Courses\\Introduction to Computing\\Spring 2008\\Quizzes\\OperatorTest.java,C:\\Documents and Settings\\<anonymized user.name>\\My Documents\\Courses\\Introduction to Computing\\Code\\Branching Code\\SwitchTest.java] window.height = 733 window.width = 1215 window.x = 63 window.y = 7 doc.list.width = 128 last.dir = C:\\Documents and Settings\\<anonymized user.name>\\My Documents\\Courses\\Introduction to Computing\\Spring 2008\\Labs\\Lab4\\MusicRentals.java last.interactions.dir = C:\\Documents and Settings\\<anonymized user.name>\\My Documents\\Courses\\Introduction to Computing\\Spring 2008\\Labs\\Lab4 Used memory: about 14.23 megabytes Free memory: about 5.10 megabytes Total memory: about 19.32 megabytes Total memory can expand to: about 127.06 megabytes ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=438935&aid=1894022&group_id=44253 |