Import TerminalIO.KeyboardReader;

I am seeming to have trouble with NetBeans(Newest Version). I can not use import TerminalIO.KeyboardReader;, there is a red line underneath it so when i compile, it keeps on saying there's an error. any wyas to fix this?

Read this - especially reply #7: http://www.xtremevbtalk.com/showthread.php?t=105296

Similar Messages

  • Import TerminalIO.KeyboardReader Error

    Hi,
    I'm using JCreator Pro and get the following error when trying to compile my programs:
    --------------------Configuration: j2sdk1.4.1_05 <Default>--------------------
    C:\Program Files\Xinox Software\JCreator Pro\MyProjects\weekpaycalculator.java:1: ';' expected
    import TerminalIO.KeyboardReader
    ^
    C:\Program Files\Xinox Software\JCreator Pro\MyProjects\weekpaycalculator.java:1: package TerminalIO does not exist
    import TerminalIO.KeyboardReader
    ^
    C:\Program Files\Xinox Software\JCreator Pro\MyProjects\weekpaycalculator.java:4: cannot resolve symbol
    symbol : class KeyboardReader
    location: class weekpaycalculator
    KeyboardReader reader = new KeyboardReader();
    ^
    C:\Program Files\Xinox Software\JCreator Pro\MyProjects\weekpaycalculator.java:4: cannot resolve symbol
    symbol : class KeyboardReader
    location: class weekpaycalculator
    KeyboardReader reader = new KeyboardReader();
    ^
    4 errors
    Process completed.
    How do I fix this problem? I have Java 2 SDK Version 1.4.1 for Win 2000 on my PC.

    i also expereinced that problem. that program is one of the exercises from the computer book published by thomson. this is what i did to fix it.
    you must include in the directory of your project the folder "TerminalIO" which contains the subfolders "TerminalIO jar file" (which contains the TerminalIO.jar) and "TerminalIO source" (which contains the "keyboardreader.java and ScreenWrite.java).
    you can copy this folder/files from the CD that comes with the book from thomson publishing company.
    If you are using JCreator you can add the directory by clicking on the project that you created then click "Project/Add directory" then browse for the folder that contains the TerminalIO folder.

  • Having problems with JPassword fields combined with terminalIO

    i copy pasted the code from the java tutorials of the JPasswordField program PasswordDemo. the code is found here... http://java.sun.com/docs/books/tutorial/uiswing/components/examples/PasswordDemo.java
    then i went to the part that defines what the program does if the password is correct and copy pasted one of my programs in. i did this twice. one with a terminalIO program and one with a JOptionPane program. for some reason the JOptionPane works but the TerminalIO freezes the program and does not allow me to type anything into it. Does anybody have any sugestions on how to fix this other than translating the code to a JOptionPane program?
    any help is greatly appreciated.

    and this is the whole program so that you can put it into an editor:
    import TerminalIO.KeyboardReader;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    /* PasswordDemo.java requires no other files. */
    public class PasswordDemo extends JPanel
    implements ActionListener {
    private static String OK = "ok";
    private static String HELP = "help";
    private JFrame controllingFrame; //needed for dialogs
    private JPasswordField passwordField;
    public PasswordDemo(JFrame f) {
    //Use the default FlowLayout.
    controllingFrame = f;
    //Create everything.
    passwordField = new JPasswordField(10);
    passwordField.setActionCommand(OK);
    passwordField.addActionListener(this);
    JLabel label = new JLabel("Enter the password: ");
    label.setLabelFor(passwordField);
    JComponent buttonPane = createButtonPanel();
    //Lay out everything.
    JPanel textPane = new JPanel(new FlowLayout(FlowLayout.TRAILING));
    textPane.add(label);
    textPane.add(passwordField);
    add(textPane);
    add(buttonPane);
    protected JComponent createButtonPanel() {
    JPanel p = new JPanel(new GridLayout(0,1));
    JButton okButton = new JButton("OK");
    JButton helpButton = new JButton("Help");
    okButton.setActionCommand(OK);
    helpButton.setActionCommand(HELP);
    okButton.addActionListener(this);
    helpButton.addActionListener(this);
    p.add(okButton);
    p.add(helpButton);
    return p;
    public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    if (OK.equals(cmd)) { //Process the password.
    char[] input = passwordField.getPassword();
    if (isPasswordCorrect(input))
    KeyboardReader reader = new KeyboardReader();
    System.out.println("Enter a number: ");
    int theInteger = reader.readInt();
    System.out.println(theInteger);
    else {
    JOptionPane.showMessageDialog(controllingFrame,
    "Invalid password. Try again.",
    "Error Message",
    JOptionPane.ERROR_MESSAGE);
    //Zero out the possible password, for security.
    for (int i = 0; i < input.length; i++) {
    input[i] = 0;
    passwordField.selectAll();
    resetFocus();
    } else { //The user has asked for help.
    JOptionPane.showMessageDialog(controllingFrame,
    "You can get the password by searching this example's\n"
    + "source code for the string \"correctPassword\".\n"
    + "Or look at the section How to Use Password Fields in\n"
    + "the components section of The Java Tutorial.");
    * Checks the passed-in array against the correct password.
    * After this method returns, you should invoke eraseArray
    * on the passed-in array.
    private static boolean isPasswordCorrect(char[] input) {
    boolean isCorrect = true;
    char[] correctPassword = { 'b', 'u', 'g', 'a', 'b', 'o', 'o' };
    if (input.length != correctPassword.length) {
    isCorrect = false;
    } else {
    for (int i = 0; i < input.length; i++) {
    if (input[i] != correctPassword) {
    isCorrect = false;
    //Zero out the password.
    for (int i = 0; i < correctPassword.length; i++) {
    correctPassword[i] = 0;
    return isCorrect;
    //Must be called from the event-dispatching thread.
    protected void resetFocus() {
    passwordField.requestFocusInWindow();
    * Create the GUI and show it. For thread safety,
    * this method should be invoked from the
    * event-dispatching thread.
    private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("PasswordDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //Create and set up the content pane.
    final PasswordDemo newContentPane = new PasswordDemo(frame);
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newContentPane);
    //Make sure the focus goes to the right component
    //whenever the frame is initially given the focus.
    frame.addWindowListener(new WindowAdapter() {
    public void windowActivated(WindowEvent e) {
    newContentPane.resetFocus();
    //Display the window.
    frame.pack();
    frame.setVisible(true);
    public static void main(String[] args) {
    //Schedule a job for the event-dispatching thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();

  • Anyone Want to Help me?(10 Duke dollars to best answer)

    i need help figuring out in this code how to ask "Would You Like To Continue Shopping". Well i know how to ask but i dont know how to end and give subtotal if the answer is no and if the answer is yes i dont know how to have my program repeat
    import TerminalIO.KeyboardReader;
    public class Grocery
    public static void main (String [] args)
    KeyboardReader reader = new KeyboardReader();
    double item;
    double quantity;
    double totalcost;
    System.out.print("Apple is 1; Bread is 2; Milk is 3");
    reader.pause();
    System.out.print("Enter Item: ");
    item = reader.readDouble();
    System.out.print("Enter Quantity: ");
    quantity = reader.readDouble();
    if (item == 1){item = .5;}
    if (item == 2){item = 1.0;}
    if (item == 3){item = 2.5;}
    totalcost = item * quantity;
    System.out.print("Total is: ");
    System.out.println(totalcost);
    reader.pause();
    someone help please!
    -Joker-

    I don't have TerminalIO, so I've changed that part of the code, perhaps you can incorporate part of this
    import java.io.*;
    public class Grocery
      public static void main (String [] args)
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        double items[] = {.5,1.0,2.5};
        String item, quantity;
        double totalcost;
        String continueShopping = "Y";
        while(continueShopping.toUpperCase().equals("Y"))
          try
            System.out.print("Apple is 1; Bread is 2; Milk is 3\nEnter Item: ");
            item = stdin.readLine();
            System.out.print("\nEnter Quantity: ");
            quantity = stdin.readLine();
            totalcost = items[Integer.parseInt(item)-1] * Integer.parseInt(quantity);
            System.out.println("Total is: " + totalcost);
            System.out.print("\nContinue shopping? (y/n)");
            continueShopping = stdin.readLine();
          catch(Exception e)
            System.out.println("Error - invalid data, terminating");
        System.exit(0);
    }

  • I need help  with compiling different packages

    I've just downloaded j2sdk1.4.0_03 and when i use
    import TerminalIO.KeyboardReader;
    it says : package TerminalIO does not exist;
    and it also has a problem with KeyboardReader.
    Please help me!

    The TerminalIO is not part of standard java classes. Some one must have given that to you, or needs to give it to you. It might be in a jar file. Without knowing what/where the TerminalIO package is, it is difficult to help you.
    If the package is in a jar, then you need to include the jar in your Classpath when you compile. If it is not in a jar, then the directory that contains the TerminalIO directory needs to be in the Classpath.
    http://java.sun.com/docs/books/tutorial/java/interpack/packages.html

  • Having trouble with drawing a Car with TurtleGraphics

    hey guys
    i need help on a program that should draw a car, erase it, and draw it again but in a different spot on the window. Now I have all of this except when the car is drawn again the wheels aren't moved with the car.
    Heres the main:
    import TurtleGraphics.StandardPen;
    import java.awt.Color;
    import TerminalIO.KeyboardReader;
    public class TestCar
    public static void main(String[] args)
      KeyboardReader reader = new KeyboardReader();
      Car firstCar = new Car();
      firstCar.drawCar();
      reader.pause();
      firstCar.eraseCar();
      reader.pause();
      Car secondCar = new Car(100, 100);
        secondCar.drawCar();
    } Here is the class:
      import TurtleGraphics.StandardPen;
    import java.awt.Color;
    public class Car {
    private StandardPen pen;
    private double xPosition, yPosition;
    public Car ()
       xPosition = 0;
       yPosition = 0;
       pen = new StandardPen();
       pen.setColor(Color.red);
    public Car(double x, double y)
       this();
       xPosition = x;
       yPosition = y;
    public void drawCar()
        drawRectangle (-150,75, 300, 150);
        drawRectangle (-50, 125, 100, 50);
        drawCircle (124, -230, 40);
        drawCircle (-124, -230, 40);
      public void drawRectangle (double x, double y, double length, double width)
        pen.up();
        pen.move(x + xPosition, y + yPosition);
        pen.down();
        pen.setDirection(270);
        pen.move(width);
        pen.turn(90);
        pen.move(length);
        pen.turn(90);
        pen.move(width);
        pen.turn(90);
        pen.move(length);
      public void drawCircle(double x, double y, double radius)
       double side = 2.0 * Math.PI * radius / 120.0;
       pen.up();
       pen.move((xPosition + x + radius), ((yPosition + y) - side)/ 2.0);
       pen.setDirection(90);
       pen.down();
        for(int i = 0; i< 120; i++) 
         pen.move(side);
         pen.turn(3);
    public void eraseCar()
        pen.setColor(Color.white);
        drawCar();
        pen.setColor(Color.red);
    } Also the car is supposed to move across the screen once drawn the second time but i haven't figured that out yet. Maybe with a thread:
    public void oneSec()
       try
       Thread.currentThread().sleep(1000);
       catch (InterruptedException e)
         e.printStackTrace();
       }  If anyone can help it'd help alot thanks

    i fixed the part about the wheels now but im stuck on how to make the car move on the turtleGraphics window once it is drawn the second time.
    Would this thread help it at all?
    public void oneSec()
       try
       Thread.currentThread().sleep(1000);
       catch (InterruptedException e)
         e.printStackTrace();
      }

  • Method Sleep --Newbie

    I am new to java, and im currently taking a class in high school on it. It is the beginning of the year so you know that I don't know a lot.
    I'm doing some experiments to help me learn more than just copying the programs my teacher gives me. So, i've done enough in turtlegraphics and now I want to get more in depth with terminalIO. I want to display stuff, and pause in between lines, but not where the user has to push enter, becuz that looks dumb. I want to use a sleep method. Ok, this means new stuff that I haven't learned yet. Could anyone help me out wiht a link to a tutorial or how I can use these sleeps. The API's are useless to newbies, they are just a bunch of what is going on's. I tried many things, and in the sun.com api, i noticed i need to do something with threads. I have some code, if some one could point me in the right direction or fix what I have wrong here it will be much appreciated. Thank you so much.
    //Code:
    import java.lang.*;
    import TerminalIO.KeyboardReader;
    public class RabbitHole {  //RabbitHole is the name of my project
         public static void main (String [] args) {
         //Use this to allow inputs
         KeyboardReader reader = new KeyboardReader();
         Thread threader = new Thread(); //Im not sure if this is correct
    threader.sleep(2000); //This gives me an error
    //but is where I want the 2 second sleep
    System.out.print ("Hello");
    //End of Code
    Thanks again for any help provided.

    Also, if I want to have the effect of text appearing
    as if someone was typing it right them, like a very
    small amont of time, x, in between every letter. I
    could do:
    System.out.print("H");
    try {
    Thread.sleep(x); }
    catch(InterruptedException ie) {}
    System.out.print("I");
    try {
    Thread.sleep(x); }
    catch(InterruptedException ie) {}
    Systme.out.print("!");
    For this it won't matter much, but with a lot of
    characters, it would look cool. Is there a simpler
    way to do this? Thankyou.
    StringBuffer sentence = new StringBuffer("Hello world!");
    for (int i = 0; i < sentence.length(); i++) {
        System.out.print(sentence.charAt(i));
        try {
            Thread.sleep(100);
        } catch(InterruptedException ie) {}

  • Trouble locating import statement

    I am fairly new to programming. I am trying to use NetBeans to create and run programs. but when i type in the program and try to compile I get the following error message.
    Please Help!!!!!!!!!????????????
    C:\Documents and Settings\nharris\MomentumAndKineticEnergy\src\momentumandkineticenergy\Main.java:10: package teminalIO does not exist
    import teminalIO.KeyboardReader;

    Maybe I should be a little more descriptive about my purpose in these questions. I am teaching Java to high school students. I have not looked at Java before this summer since 1999. I am also taking a Into to programming logic as a refresher to help to better do my job. I was told to download the JDK with Netbeans and it would be easy to use. But I am having more problems than you can possible imagine. I got that downloaded and was able to run "Hello World". But anything that is required for me to put input is not working. I took a sample project from the book and tried to run but it did not work the sample project or code was TestTerminalIO from the textbook: Fundamentals of Java: Second Edition. This is were the TerminalIO.Keyboardreader is from.
    Any suggestions on what to use or do will greatly be appreciated. This an introductory class of future programmers.

  • Trouble with import

    Hey, I'm very new to java and all object oriented programming. Could somebody tell me how to make this work, I think I need to get TerminalIO but do not know how or where to put it. Here's my code.
    import TerminalIO.*;
    public class Convert{
         public static void main(String []args){
              KeyboardReader reader = new KeyboardReader();
              double fahrenheit;
              double celsius;
              System.out.println("Enter degrees Farenheit");
              fahrenheit = reader.readDouble();
              celsius = (fahrenheit - 32) * 5 / 9;
              System.out.println("The equivalent in Celsius is " + celsius);
    it says it can't resolve the symbol KeyboardReader when compiled.

    I think I need to get TerminalIO but do not know how or where to put it. Here's my code.TerminalIO is not an standard package so you will need to get it from the tutorial/book/lab etc you are using, once you get it, set your classpath to point to this folder/package.
    it says it can't resolve the symbol KeyboardReader when compiled. because it is part of the package, which it cannot find.

  • Error by submitting objects with socket

    Hallo,
    I allways get the following error massage:
    Error:
    java.net.ConnectException: Connection timed out: connect
    Exception in thread "Thread-0" java.lang.NullPointerException
    at com.Receiver.read(Receiver.java:36)
    at Input.write(Kommunicator.java:111)
    at Input.run(Kommunicator.java:137)
    Error:
    java.net.ConnectException: Connection timed out: connect
    Here is my code:
    import com.*;
    import TerminalIO.*;
    import java.util.*;
    import java.io.*;
    import java.net.*;
    public class Kommunicator
         public static void main(String [] args){
              KeyboardReader inread = new KeyboardReader();
              int port = inread.readInt();
              String ip =inread.readLine();
              Emitter out = new Emitter(ip, port);
              Input in= new Input(new Receiver(ip, port));
              try{
                   in.start();
                   boolean flag=true;
                   while(flag){
                        out.open();
                        if(line.equalsIgnoreCase("\\quit")){
                             out.write("User left");
                             in.interrupt();
                             flag=false;
                        else{
                             out.write(line);
                        out.close();
              catch(IOException e){
                   System.out.println("Error:\n"+e.toString());
    class Input extends Thread
         private Receiver out;
         public Input(Receiver a){out=a;}
         private void open(){
              try{
                   out.open();
                   super.start();
              catch(IOException e)
                   System.out.println("Error:\n"+e.toString());
         private void close(){
              try{
                   out.close();
              catch(IOException e)
                   System.out.println("Error:\n"+e.toString());
         private void write(){
              try{
                   Object temp=out.read();
                   if(!temp.equals(null))
                        String line=temp.toString();
                        do
                        System.out.println("Other:"+line);
                        line=out.read().toString();
                        }while(!line.equals(""));
              catch(IOException e)
                   System.out.println("Error:\n"+e.toString());
              catch(ClassNotFoundException e)
                   System.out.println("Error:\n"+e.toString());
         public void run()
              open();
              write();
              close();
    package com;
    import java.net.*;
    import java.io.*;
    public class Receiver
         private String ip;
         private int port;
         private ObjectInputStream ois;
         private Socket sock;
         public Receiver(String a, int b)
              ip=a;
              port=b;
         public void open() throws IOException
              sock = new Socket(InetAddress.getByName(ip), port);
              ois = new ObjectInputStream(sock.getInputStream());
              sock.setSoTimeout(3000);
         public void close() throws IOException
              ois.close();
              sock.close();
         public Object read() throws IOException,ClassNotFoundException
              Object temp=null;
              temp=ois.readObject();
              return temp;
         public int getPort()
         {return port;}
         public String getIp()
         {return ip;}
    package com;
    import java.io.*;
    import java.net.*;
    public class Emitter
         private String ip;
         private int port;
         private Socket sock;
         private ObjectOutputStream oos;
         public Emitter(String a, int b)
              ip=a;
              port=b;
         public String getIp()
         {return ip;}
         public int getPort()
         {return port;}
         public void open() throws IOException
              sock = new Socket(InetAddress.getByName(ip),port);
              oos =new ObjectOutputStream(sock.getOutputStream());
              sock.setSoTimeout(3000);
         public void write(Object a) throws IOException
         {oos.writeObject(a);}
         public void close() throws IOException
              oos.close();
              sock.close();
    }I hope you can help me with my problem and I hope you can answer my questions;
    1) is it a general problem with socket, that it is not allowed to submit objects on a permanent way?
    2) is it there another way how to submit object?
    3) can the problem be caused through trying to submit packeges in a lan?

    1. When you get an exception trying to construct any object, it is poor practice to print and ignore it.
    2. It is invalid to continue as though the object had been constructed.
    3. In this case you failed to connect but then continued to the read method using a null socket reference.
    4. You need to restructure your code so that it reacts correctly to exceptions.
    5. Then you need to solve the question of why the connect failed.

  • Can you have code run in a terminal and applet?

    For example in my program in Main we enter the data for menu and amount of the exchange but the result is displayed in an applet.
    works great in the terminal window.
    but when using an applet it will not work.
    import java.awt.*;
    import java.applet.*;
    import javax.swing.* ;
    import TerminalIO.*;
    public class MetricConversionMain    {
             final static String CRLF = "\n" ;     
             static String msgOut ;                   
         public static void main ( String[] args )     {
            int valid  = 0;
            int choose = 0;
            double numUnits = 0.0; 
            double convertedUnits = 0.0;
                                  // title, class, author and version info  to
         KeyboardReader entries = new KeyboardReader(); //object for keyboard entry
         while (valid != 1) {
                // menu for conversion selection 1 thru 4          
         System.out.println("\n\t\t1 \tFor inches to centimeters");
          System.out.println("\t\t2 \tFor quarts to liters");
          System.out.println("\t\t3 \tFor pounds to kilograms");
          System.out.println("\t\t4 \tFor miles to Kilometer");
              choose = // GW corrected my code to the present prior I was choose = choose.readInt etc etc
            entries.readInt("\n\t\tPlease choose one of the following menu items to convert: ");
          if (choose == 1 || choose == 2 || choose == 3 || choose ==4 ) {
               valid = 1 ;
          else {
               System.out.println("Invalid Selection.") ;
          switch (choose) {
              case 1 : System.out.println("Converting inches to centimeters... ") ; break ;
              case 2 : System.out.println("Converting quarts to liters... ") ; break ;
              case 3 : System.out.println("Converting pounds to kilograms... ") ; break ;
              case 4 : System.out.println("Converting miles to kilometers... ") ; break ;
         } // Error checking, reiterates the user's current choice prior to next question
         System.out.println();
         KeyboardReader useEntry = new KeyboardReader(); //object for keyboard entry
              numUnits =
            useEntry.readDouble("\n\t\tNow please enter the amount you wish to convert: ");
              System.out.println ("\t\tThe conversion comes to  " + numUnits);
         //KeyEntry equal = new KeyEntry();   
         //equal.setNumUnits
        //(useEntry.readDouble("\n\t\tNow please enter the amount you wish to convert: "));
         //System.out.println("\t\tThe conversion comes to  " + getnumUnits());
         switch (choose) {
              case 1 : Inch fromInch = new Inch(numUnits); break ;}
         case 2 : Quart fromQuart = new Quart(numUnits) ; break ;
              /*     case 3 : Pound fromPound = new Pound( numUnits) ; break ;
              case 4 : Mile fromMile = new Mile(numUnits) ; break ;
         } // Switch statement that performs the correct conversion based on the user's input*/
                   // Instantiate US Standard Objects
         /*     Inch fromInch = new Inch(1) ;
              Foot fromFoot = new Foot(1) ;
              Yard fromYard = new Yard(1) ;
              Mile fromMile = new Mile(1) ;
              Ounce fromOunce = new Ounce(1) ;
              Quart fromQuart = new Quart(1) ;
              Gallon fromGallon = new Gallon(1) ;
              Pound fromPound = new Pound(1) ;
              // Instantiate Metric Objects          
              Centimeter fromCentimeter = new Centimeter(1) ;
              Meter fromMeter = new Meter(1) ;
              Kilometer fromKilometer = new Kilometer(1) ;
              Gram fromGram = new Gram(1) ;
              Liter fromLiter = new Liter(1) ;
              Kilogram fromKilogram = new Kilogram(1) ;
              LitGal fromLitGal = new LitGal(1) ; */
         }     //  main
    }     //     class MetricConversionMainsupper classpublic class SuperConverter        {
         *     This class is the super class for a series of
         *     subclasses that perform conversion from metric to
         *     imperial or vice versa.
         protected double numUnits ;
         protected double convertedUnits ;
         protected double factor ;
         // Constructor
         public SuperConverter ( double argNumUnits, double argFactor )  {     
         numUnits = argNumUnits ;
         factor = argFactor ;
         convertedUnits = numUnits * factor ; //convert() ;
         }     // Constructor
         protected double getnumUnits()     {
              return numUnits ;
         protected void setnumUnits     ( double argNumUnits )     {
              numUnits = argNumUnits ;
         protected double convert  () {
              this.convertedUnits = numUnits * factor ;     
              return convertedUnits ;     
         public double getconvertedUnits()     {
              this.convertedUnits = convert() ;
              return convertedUnits ;
    }     //  end SuperConverter Classsubclass that works[public class Inch extends SuperConverter {
         public Inch      (double argNumUnits)
              super ( argNumUnits, 0.914 ) ;
              System.out.print   ("     ") ;
         if (argNumUnits > 1)
                   System.out.println(argNumUnits + " inches = " + convertedUnits + " centimeters") ;
              else
                   System.out.println(argNumUnits + " inch = " + convertedUnits + " centimeters") ;
    /code]
    The code I want to use  with the applet is import java.awt.*;
    import java.applet.*;
    import javax.swing.* ;
    public class Inch extends SuperConverter {
         final static String CRLF = "\n" ;     
         static String msgOut ;          
         public Inch      (double argNumUnits)
              super ( argNumUnits, 2.54 ) ;
              System.out.print ("     ") ;
              if (argNumUnits > 1)
              {   msgOut = "     Metric Conversion Chart" + CRLF + CRLF;
              msgOut += "     US Standard to Metric" + CRLF ;
         msgOut += "     -------------------------------------------------" + " " + CRLF ;
                   msgOut = argNumUnits + " inches = " + convertedUnits + " centimeters" ;
              else
              {   msgOut = "     Metric Conversion Chart" + CRLF + CRLF;
              msgOut += "     US Standard to Metric" + CRLF ;
         msgOut += "     -------------------------------------------------" + " " + CRLF ;
                   msgOut += argNumUnits + " inch = " + convertedUnits + " centimeters" + CRLF + CRLF + CRLF ;
              }     JOptionPane.showMessageDialog ( null, msgOut ) ;          
    }

    The issue I have is the applet/window appears behind the terminal window. below is the code that is use for the window. I want to have the window appear infront of the terminal window.import java.awt.*;
    import java.applet.*;
    import javax.swing.* ;
    public class Pound extends SuperConverter {
        final static String CRLF = "\n" ;     
             static String msgOut ;     
         public Pound      (double argNumUnits)
              super ( argNumUnits, 0.454 ) ;     
              System.out.print   ("     ") ;     
              if (argNumUnits > 1)
              {   msgOut = "     Metric Conversion Chart" + CRLF + CRLF;             
                  msgOut +=  "     Metric to US Standard" + CRLF ;
                  msgOut +=  "     -------------------------------------------------" + "         " + CRLF ;
                   msgOut += argNumUnits + " pounds = " + convertedUnits + " kilograms" + CRLF + CRLF + CRLF ;
              else
              {   msgOut = "     Metric Conversion Chart" + CRLF + CRLF;
                  msgOut +=  "     Metric to US Standard" + CRLF ;
                  msgOut +=  "     -------------------------------------------------" + "         " + CRLF ;
                   msgOut += argNumUnits + " pound = " + convertedUnits + " kilograms" + CRLF + CRLF + CRLF ;
              }   JOptionPane.showMessageDialog ( null, msgOut ) ;
    }

  • Program issues

    Hi,
    Im having trouble with the following, i can get it to compile, but thats about all.
    The program wont display any of the messageBoxes, any help would be great.
    import TerminalIO.*;
    public class Factor3{
       KeyboardReader reader = new KeyboardReader();
       ScreenWriter writer = new ScreenWriter();
       int trialfactor;
       int sum;
       int number;
       public void run(){
          number = reader.readInt("Please enter a number: ");
          sum = 0;
          trialfactor = 1;
          while(trialfactor <= (number/2)){
             if(number % trialfactor == 0){
                sum = (trialfactor + sum);
             }else{
             trialfactor = (trialfactor + 1);
          if (trialfactor > (number/2)){
             if (sum < number){
                writer.println ("Deficient");
             }else if (sum == number){
                writer.println ("Perfect");
             }else if (sum > number){
                writer.println ("Abundant");
             writer.println (trialfactor);
             writer.println (sum);
          public static void main (String [] args) {
                Factor3 tpo = new Factor3();
                tpo.run();
    }

    woops, wrong code :-S
    no, haven't looked for it yet, might have a go now
    import javax.swing.*;
    import BreezySwing.*;
    public class FactorGUI extends GBFrame{
       JLabel NumberLabel = addLabel
       ("Number" ,1,1,1,1);
       //JLabel trialfactorLabel = addLabel
       //("Trialfactor" ,1,2,1,1);
       IntegerField numberField = addIntegerField
       (0,2,1,1,1);
       //IntegerField trialfactorField = addIntegerField
       //(0.0,2,2,1,1);
       JButton NumberButton = addButton
       (">>>>>>" ,3,1,1,1);
       int sum;
       int trialfactor;
       int number;  
       public void buttonClicked (JButton buttonObj){
          if(trialfactor <= (number/2)){
             if(number % trialfactor == 0){
                sum = (trialfactor + sum);
             }else{
             trialfactor = (trialfactor + 1);
          if (trialfactor > (number/2)){
             if (sum < number){
                messageBox("Deficient");
             }else if (sum == number){
                messageBox("Perfect");
             }else if (sum > number){
                messageBox("Abundant");
          public static void main (String[] args) {
             FactorGUI tpo = new FactorGUI();
             tpo.setSize(320, 200);
             tpo.setVisible(true);
    }

  • Java code to pseudocode

    Hi, i have written this program but I also need to submit the pseudo code for it and i'm not really sure how to do this.
    Here is a sample of the code I have written, if someone could please get me on the write track so i can write the pseudocode for the whole thing that would be great.
    Java code;
    import TerminalIO.*;
    public class MyFutureTIO
    KeyboardReader reader = new KeyboardReader();
    ScreenWriter writer = new ScreenWriter();
    public void run()
    // global instance variables
    char keepdepositing='N';
    double deposit, rate, balance=0 , withdrawals=0, interest=0, withdrawalyears=0, finalbalance=0, counter=0;
    int age, years=0, continuedyears=0;
    // Initial inputs to be able to determine when the loan matures
    writer.print("Amount deposited per month: ");
    deposit = reader.readDouble();
    writer.print("Your age: ");
    age = reader.readInt();
    writer.print("Interest rate: ");
    rate = reader.readDouble();
    deposit = deposit*12;     // This is the yearly deposit amount
    rate = rate/100;          // To convert the rate to a decimal
    if (age >=60){      // This if statement is used when the age is over 60 years
    years = 0;
    for (int i = 0; i < years; i++)
    balance = (balance + deposit) * (1 + rate);
    if (counter % 10==0)
    rate = rate + 0.01;
    counter++;
    writer.print("As you are 60 or older, your account is at maturity\n");
    writer.print("Your account has a $" + balance +", but you can choose to deposit money from this point onwards\n");
    writer.print("Would you like to start depositing?\n");
    keepdepositing = reader.readChar();          
    if (keepdepositing == 'N'){  //the user doesn't want to open an account
    writer.print("As you don't want to start depositing and your account has a $0 balance no account has been opened\n");
    else if (keepdepositing == 'Y'){   //the user wants to start depositing into the account
    writer.print("How many years would you like to deposit for? ");
    continuedyears = reader.readInt();
    for (int i = 0; i < continuedyears; i++)
    balance = (balance + deposit) * (1 + rate);
    writer.print("Your balance at this time will be: $" + balance);
    interest = (balance*rate)/12;
    writer.print("Your account will earn $" + interest + " per month in interest after this point\n");
    writer.print("How much would you like to withdraw per month? ");
    withdrawals = reader.readDouble();
    writer.print("How many years would you like to withdraw for? ");
    withdrawalyears = reader.readDouble();
    for (int i = 0; i < withdrawalyears; i++) // do i need the counter here?
    finalbalance = (balance - withdrawals*12)*(1 + rate);
    writer.print("After this time your account will have a balance of: $" + finalbalance + "\n");
    }

    Yeah i did write this program, and i have actaully started to write the pseudocode but it doesn't seem write, i'm not sure if i'm putting to much in or not enough.
    All of my notes say not to use any java key words in pseudocode, and this is confusing me a bit.
    This is what I started to write for the psuedocode;
    Get deposit
    Get age
    Get rate
    If (age >= 60
    years = 0
    for (int 1=0;
    Balance = (balance + deposit)*(1+rate)
    Print As you are 60 or older, your account has reached maturity
    Print Your account has a $0 balance, but you can choose to deposit money from this point onwards
    Print Would you like to start depositing?
    if (keepdepositing == �N�)
    Print As you don�t want to start depositing and your account has a $0 balance no account has been opened�
    else if (keepdepositing == �Y�)
         Print How many years would you like to deposit for?
         Balance = (balance + deposit) * (1 + rate)
         Print Your balance at this time will be $balance
         interest = (balance*rate)/12
         Print Your account will earn $interest per month after this point
         Print How much would you like to withdraw per month?
         Print How many years would you like to withdraw for?
         final balance = (balance � withdrawals*12)*(1 + rate)
         Print After this time your account will have a balance of $finalbalance

  • IsNaN doesn't work

    Here's some simple program I created (or part of it):
        while (!(mass >= 0) || (Double.isNaN(mass) == true)){
             System.out.print("Mass: ");
             mass = reader.readDouble();
           }I set imported TerminalIO and near the top set the double mass to -1. When I run the whole program and put in something like "cheeseburgers," I get the same message I do when I put in a double value:
    Mass: cheeseburgers
    Error: your input doesn't represent a valid double value
    Press Enter to continue . . .The rest of the program doesn't matter, but it's this one section that I'm stuck on. Any suggestions?

    Information on KeyboardReader:
    http://www.int.gu.edu.au/courses/1002int/resources/JavaDocs/TerminalIO/KeyboardReader.html
    For computers that don't have the Sanner class, it's really helpful :)
    Also, I thought of the try-catch statements, but those only loop once. If someone enters "cheese", gets the prompt again, and enters "hello", then the program will end. (Or I could have a bunch of try-catch statements inside each other :) )

  • Utter confusion

    Hi, ive got an exercise to complete, ive been given some equations to use to find the results needed but i dont know how to apply them. I really need some help with finding a way to tie the bits together to get a working program. So far its just full of errors.
    Here's what the output should end up looking like.
    gravity (m/s/s): -1.6
    height (m): 1000
    velocity (m/s): -100
    burn (m/s/s): 0
    height = 899.2 (m); velocity = -101.6 (m/s); burn (m/s/s): 0
    height = 796.8 (m); velocity = -103.2 (m/s); burn (m/s/s): 0
    height = 692.8 (m); velocity = -104.8 (m/s); burn (m/s/s): 10
    height = 592.2 (m); velocity = -96.4 (m/s); burn (m/s/s): 10
    height = 500.0 (m); velocity = -88.0 (m/s); burn (m/s/s): 10
    height = 416.2 (m); velocity = -79.6 (m/s); burn (m/s/s): 10
    height = 340.8 (m); velocity = -71.2 (m/s); burn (m/s/s): 10
    height = 273.8 (m); velocity = -62.8 (m/s); burn (m/s/s): 10
    height = 215.2 (m); velocity = -54.4 (m/s); burn (m/s/s): 10
    height = 165.0 (m); velocity = -46.0 (m/s); burn (m/s/s): 10
    height = 123.2 (m); velocity = -37.6 (m/s); burn (m/s/s): 5
    height = 87.3 (m); velocity = -34.2 (m/s); burn (m/s/s): 10
    height = 57.3 (m); velocity = -25.8 (m/s); burn (m/s/s): 10
    height = 35.7 (m); velocity = -17.4 (m/s); burn (m/s/s): 10
    height = 22.5 (m); velocity = -9.0 (m/s); burn (m/s/s): 5
    height = 15.2 (m); velocity = -5.6 (m/s); burn (m/s/s): 3
    height = 10.3 (m); velocity = -4.2 (m/s); burn (m/s/s): 3
    height = 6.8 (m); velocity = -2.8 (m/s); burn (m/s/s): 2
    height = 4.2 (m); velocity = -2.4 (m/s); burn (m/s/s): 2
    height = 2.0 (m); velocity = -2.0 (m/s); burn (m/s/s): 2
    height = 0.2 (m); velocity = -1.6 (m/s); burn (m/s/s): 2
    surface velocity = -1.6 (m/s). Crash!
    and here's my poor excuse for code
    import TerminalIO.*;
    public class Lander{
       KeyboardReader reader = new KeyboardReader
       SreenWriter writer = new ScreenWriter
       int h;
       int v;
       double g;
       int b;
       public void run(){
          int h = reader.readInt("Please enter height: ");
          int v = reader.readInt("Please enter velocity: ");
          double g = reader.readDouble("Please enter gravity ");
          int b = 0;
          while (h > 0){
             int h = writer.println("Height" + (h + v + (g+b)/2));
             int b = reader.readInt ("Enter burn: ");
             int v = writer.println ("Velocity" + (v+(g+b)));
          while (h == 0){
             int h = 0;
             int v = writer.println (-Math.sqrt(2(g+b)h + (v^2))));
             //int h = h<=0;
          public static void main (String [] args) {
             Lander tpo = new Lander();
             tpo.run();
    }

    cross post.
    http://forum.java.sun.com/thread.jspa?forumID=54&threadID=612698

Maybe you are looking for

  • Help with XIRR Function

    Is there any way in Numbers 08 to add an XIRR Function. This is one of the most useful functions for calculating Total Return of any Portfolio and it isn't included. Is it included in Numbers 09? I really miss this Function Thanks in advance.

  • Iphone os problem

    when publish the iphone os ,if the the  *.actionscript file should be added in the  contain files? and if the action "touch" in iphone os is the "click" action?

  • OSB and dynamic routing

    we are trying to implement dynamic routing using xquery resource like in documentation http://edocs.bea.com/alsb/docs30/userguide/modelingmessageflow.html#wp1100135 when configuring proxy service while adding the expresssion: <ctx: route><ctx: servic

  • Got Error in using JDBC

    I have got the following error when I am running my application using JDBC. It works fine but after running long time I have got this error. java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=153092352)(ERR=12500)(ERROR

  • New To FI/CO

    Dear Sappers! As we all know SAP is the leader of ERP. I took training in SAP FICO and been practicing on it for the last 3 months. Now I am ready and looking for a project in SAP implementation in USA. Can any one provide me some SAP FI/CO interview