This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | Console does not accept input. | ||
---|---|---|---|
Product: | platform | Reporter: | tmanningtx <tmanningtx> |
Component: | -- Other -- | Assignee: | issues@platform <issues> |
Status: | CLOSED DUPLICATE | ||
Severity: | blocker | CC: | jchalupa |
Priority: | P3 | ||
Version: | 4.x | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Issue Type: | DEFECT | Exception Reporter: |
Description
tmanningtx
2004-10-23 18:50:01 UTC
Attached is the code in question. import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; /** This program tests input from a console window. */ public class ConsoleInputTest { public static void main(String[] args) throws IOException { Purse myPurse = new Purse(); BufferedReader console = new BufferedReader( new InputStreamReader(System.in)); System.out.println("How many nickels do you have?"); String input = console.readLine(); int count = Integer.parseInt(input); myPurse.addNickels(count); System.out.println("How many dimes do you have?"); input = console.readLine(); count = Integer.parseInt(input); myPurse.addDimes(count); System.out.println("How many quarters do you have?"); input = console.readLine(); count = Integer.parseInt(input); myPurse.addQuarters(count); double totalValue = myPurse.getTotal(); System.out.println("The total is " + totalValue); } } /** A purse computes the total value of a collection of coins. */ public class Purse { /** Constructs an empty purse. */ public Purse() { nickels = 0; dimes = 0; quarters = 0; } /** Add nickels to the purse. @param count the number of nickels to add */ public void addNickels(int count) { nickels = nickels + count; } /** Add dimes to the purse. @param count the number of dimes to add */ public void addDimes(int count) { dimes = dimes + count; } /** Add quarters to the purse. @param count the number of quarters to add */ public void addQuarters(int count) { quarters = quarters + count; } /** Get the total value of the coins in the purse. @return the sum of all coin values */ public double getTotal() { return nickels * NICKEL_VALUE + dimes * DIME_VALUE + quarters * QUARTER_VALUE; } private static final double NICKEL_VALUE = 0.05; private static final double DIME_VALUE = 0.1; private static final double QUARTER_VALUE = 0.25; private int nickels; private int dimes; private int quarters; } Unfortunately true. This is a known defficiency of NB 4.0. Console apps run from the IDE can't receive input. *** This issue has been marked as a duplicate of 47708 *** closed |