Help with program

public class Reverse{
�@public static void main(String[] args)
{ int i,j;
for(i=args.length-1;i>=0;i--)
{   for (j=args[i].length()-1;j>=0;j--) System.out.print(args.charAt(j));
System.out.print(" ");
     System.out.println();
I wrote the program but there ia an error
Invalid character in input
public static void main(String[] args)
I really can not realize what is the mistake? Can anyone help me?
Thanks a lot!

public class Reverse{
�@public static void main(String[] args)You think the stuff in bold should be there? What makes you think that?

Similar Messages

  • Search help with programming

    Hai,
    Can any one give example for search help with Programming?
    I hope we can create search help with help of coding.
    With Regards,Jaheer.

    yes u can create search help by using match code in programs
    for eq
    go with abap editor se 38
    provide the name of program
    parameters : vendor like lfa1-lifnr matchcode object yzob.
    double click on yzob
    provide description for search help
    provide selection method
    provide search help parameter
    enable check box for import and export
    provide lpos
               spos
    save check activate
    press f4 for check and import values i.e it will display a records list available in database table
    rewards points please

  • Help With Program Please

    Hi everybody,
    I designed a calculator, and I need help with the rest of the scientific actions. I know I need to use the different Math methods, but what exactly? Also, it needs to work as an applet and application, and in the applet, the buttons don't appear in order, how can I fix that?
    I will really appreciate your help with this program, I need to finish it ASAP. Please e-mail me at [email protected].
    Below is the code for the calcualtor.
    Thanks in advance,
    -Maria
    // calculator
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    public class calculator extends JApplet implements
    ActionListener
    private JButton one, two, three, four, five, six, seven,
    eight, nine, zero, dec, eq, plus, minus, mult, div, clear,
    mem, mrc, sin, cos, tan, asin, acos, atan, x2, sqrt, exp, pi, percent;
    private JLabel output, blank;
    private Container container;
    private String operation;
    private double number1, number2, result;
    private boolean clear = false;
    //GUI
    public void init()
    container = getContentPane();
    //Title
    //super("Calculator");
    JPanel container = new JPanel();     
    container.setLayout( new FlowLayout( FlowLayout.CENTER
    output = new JLabel("");     
    output.setBorder(new MatteBorder(2,2,2,2,Color.gray));
    output.setPreferredSize(new Dimension(1,26));     
    getContentPane().setBackground(Color.white);     
    getContentPane().add( "North",output );     
    getContentPane().add( "Center",container );
    //blank
    blank = new JLabel( " " );
    container.add( blank );
    //clear
    clear = new JButton( "CE" );
    clear.addActionListener(this);
    container.add( clear );
    //seven
    seven = new JButton( "7" );
    seven.addActionListener(this);
    container.add( seven );
    //eight
    eight = new JButton( "8" );
    eight.addActionListener(this);
    container.add( eight );
    //nine
    nine = new JButton( "9" );
    nine.addActionListener(this);
    container.add( nine );
    //div
    div = new JButton( "/" );
    div.addActionListener(this);
    container.add( div );
    //four
    four = new JButton( "4" );
    four.addActionListener(this);
    container.add( four );
    //five
    five = new JButton( "5" );
    five.addActionListener(this);
    container.add( five );
    //six
    six = new JButton( "6" );
    six.addActionListener(this);
    container.add( six );
    //mult
    mult = new JButton( "*" );
    mult.addActionListener(this);
    container.add( mult );
    //one
    one = new JButton( "1" );
    one.addActionListener(this);
    container.add( one );
    //two
    two = new JButton( "2" );
    two.addActionListener(this);
    container.add( two );
    //three
    three = new JButton( "3" );
    three.addActionListener(this);
    container.add( three );
    //minus
    minus = new JButton( "-" );
    minus.addActionListener(this);
    container.add( minus );
    //zero
    zero = new JButton( "0" );
    zero.addActionListener(this);
    container.add( zero );
    //dec
    dec = new JButton( "." );
    dec.addActionListener(this);
    container.add( dec );
    //plus
    plus = new JButton( "+" );
    plus.addActionListener(this);
    container.add( plus );
    //mem
    mem = new JButton( "MEM" );
    mem.addActionListener(this);
    container.add( mem );
    //mrc
    mrc = new JButton( "MRC" );
    mrc.addActionListener(this);
    container.add( mrc );
    //sin
    sin = new JButton( "SIN" );
    sin.addActionListener(this);
    container.add( sin );
    //cos
    cos = new JButton( "COS" );
    cos.addActionListener(this);
    container.add( cos );
    //tan
    tan = new JButton( "TAN" );
    tan.addActionListener(this);
    container.add( tan );
    //asin
    asin = new JButton( "ASIN" );
    asin.addActionListener(this);
    container.add( asin );
    //acos
    acos = new JButton( "ACOS" );
    cos.addActionListener(this);
    container.add( cos );
    //atan
    atan = new JButton( "ATAN" );
    atan.addActionListener(this);
    container.add( atan );
    //x2
    x2 = new JButton( "X2" );
    x2.addActionListener(this);
    container.add( x2 );
    //sqrt
    sqrt = new JButton( "SQRT" );
    sqrt.addActionListener(this);
    container.add( sqrt );
    //exp
    exp = new JButton( "EXP" );
    exp.addActionListener(this);
    container.add( exp );
    //pi
    pi = new JButton( "PI" );
    pi.addActionListener(this);
    container.add( pi );
    //percent
    percent = new JButton( "%" );
    percent.addActionListener(this);
    container.add( percent );
    //eq
    eq = new JButton( "=" );
    eq.addActionListener(this);
    container.add( eq );
    //Set size and visible
    setSize( 190, 285 );
    setVisible( true );
    public static void main(String args[]){
    //execute applet as application
         //applet's window
         JFrame applicationWindow = new JFrame("calculator");
    applicationWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         //applet instance
         calculator appletObject = new calculator();
         //init and start methods
         appletObject.init();
         appletObject.start();
    } // end main
    public void actionPerformed(ActionEvent ae)
    JButton but = ( JButton )ae.getSource();     
    //dec action
    if( but.getText() == "." )
    //if dec is pressed, first check to make shure there
    is not already a decimal
    String temp = output.getText();
    if( temp.indexOf( '.' ) == -1 )
    output.setText( output.getText() + but.getText() );
    //clear action
    else if( but.getText() == "CE" )
    output.setText( "" );
    operation = "";
    number1 = 0.0;
    number2 = 0.0;
    //plus action
    else if( but.getText() == "+" )
    operation = "+";
    number1 = Double.parseDouble( output.getText() );
    clear = true;
    //output.setText( "" );
    //minus action
    else if( but.getText() == "-" )
    operation = "-";
    number1 = Double.parseDouble( output.getText() );
    clear = true;
    //output.setText( "" );
    //mult action
    else if( but.getText() == "*" )
    operation = "*";
    number1 = Double.parseDouble( output.getText() );
    clear = true;
    //output.setText( "" );
    //div action
    else if( but.getText() == "/" )
    operation = "/";
    number1 = Double.parseDouble( output.getText() );
    clear = true;
    //output.setText( "" );
    //eq action
    else if( but.getText() == "=" )
    number2 = Double.parseDouble( output.getText() );
    if( operation == "+" )
    result = number1 + number2;
    else if( operation == "-" )
    result = number1 - number2;
    else if( operation == "*" )
    result = number1 * number2;
    else if( operation == "/" )
    result = number1 / number2;
    //output result
    output.setText( String.valueOf( result ) );
    clear = true;
    operation = "";
    //default action
    else
    if( clear == true )
    output.setText( "" );
    clear = false;
    output.setText( output.getText() + but.getText() );

    Multiple post:
    http://forum.java.sun.com/thread.jsp?forum=31&thread=474370&tstart=0&trange=30

  • Can anyone help with programming co ordinates.

    how do i develop a class specification for class points.
    //pointTest.java
    main(...)     
         Point P1;
         P1.create(24,16); // create a point with coordinates {24,16}
         P1.display(); // display the {X,Y} coordinates of P1
    can anyone help with coding to program two points. can anyone elaborate on the stubs shown above to develop one point.

    There's already a Point class. So use that.
    Unless this is a homework in which case, well, it's your homework isn't it? So why are you asking us?

  • Need help with program for Inner join

    Hello Experts,
    I need to create a list from table sbook containing booking number (sbook-bookid), customer number (sbook-customid), customer name (scustom-name) , customer class (sbook-class) and ticket price (sflight-price). I am new to ABAP and am very confused I tried reading up some examples and came up with the attached program
    Attached is my program for inner join
    Kindly Help
    Thanks Su

    Hi Su K
              You May use key fields , Foreign keys for joining , Here
    SELECT SBOOK~BOOKID SBOOK~CUSTOMID SBOOK~CLASS
      SCUSTOM~ID SCUSTOM~NAME  FROM SFILGHT
       INNER JOIN SBOOK ON   SBOOK~CARRID EQ SFILGHT~CARRID
                                              SBOOK~CONNID EQ SFILGHT~CONNID
                                              SBOOK~FLDATE EQ SFILGHT~FLDATE
      INNER JOIN SCUSTOM ON SCUSTOM~ID = SBOOK~ID

  • Help with programs not opening!

    I have a Lenovo Ideapad Miix 10.
    Worked fine until recently.  Now when I try to open something like Word or Excel, they don't open.  Instead, it takes me to the desktop and does nothing.  When I go to "troubleshoot compatibility", I have the option to test the program, allow access to change the computer (or whatever its asking for..) but it still does nothing.  When I click no and select that the problem is not fixed, the troubleshooter lists incompatible program as being detected.
    This is really inconvenient, and I am still getting comfortable with the windows tablet so dont exactly know my way around yet.  anyone able to help out? thanks in advance!

    You are posting in the "icloud on my mac" forum, but your profile mentions Windows.  If using a mac, you need to have iphoto or aperture installed in order to receive new photos via photo stream.  If using windows, try posting in the iCloud on a PC forum.  You'll get better help there.
    https://discussions.apple.com/community/icloud/icloud_on_my_pc

  • Rookie needs help with program!!

    Hi everyone,
    I am new to JAVA programming and am trying to figure out my first progam. Any suggestions? Here's what I have to come up with...
    This program will test your ability to code a loop function and some work with the strings methods.
    INPUT
    A SENTENCE OF UNKNOWN LENGTH.
    OUTPUT
    THE NUMBER OF WORDS IN THE SENTENCE AND EACH WORD ON A SEPARATE LINE. Two spaces are not a word; "a" is a word.
    HINT
    Use a loop until the end of the sentence and count each word that is removed from the front of the sentence (one at a time). Each time the sentence should be shortened.
    I know I need to use a string method...Here's what I have so far...
    public class jmstr
    public static void main (String[ ] args)
    System.out.println ("Please enter a sentence starting with some spaces ");
    inputline = SavitchIn.readLine ( ) ;
    System.out.println (inputline);
    I'm not really sure what to do next....?
    Any help would be appreciated!
    materman

    http://java.sun.com/j2se/1.4.2/docs/api/java/util/StringTokenizer.html
    look at the example on the page, then scroll down to the Methods section and click on
    countTokens()

  • Help with program to remove comments from chess(pgn) text files

    Hi
    I would like to make a java program that will remove chessbase comments from pgn files (which are just based text files).
    I have done no java programming on text files so far and so this will be a new java adventure for me. Otherwise I have limited basic java experience mainly with Java chess GUI's and java chess engines.
    I show here a portion of such a pgn text file with the chessbase comments which are between the curly braces after the moves:
    1. e4 {[%emt 0:00:01]} c6 {[%emt 0:00:10]} 2. d4 {[%emt 0:00:03]} d5 {
    [%emt 0:00:01]} 3. e5 {[%emt 0:00:01]} Bf5 {[%emt 0:00:01]} 4. h4 {
    [%emt 0:00:02]} e6 {[%emt 0:00:02]}
    I want to make a java program if possible that removes these comments, so just leaving the move notation eg:
    1. e4 c6 2. d4 d5 3. e5 Bf5 4. h4 e6
    I am just starting with this. As yet I am unsure how to begin and do this and I would be extremely grateful for any help and advice to get me going with this project.
    I look forward to replies, many thanks

    I found a simple java text editor (NutPad-with sourcecode) and have tried to adapt it to incorporate the regular expressions code suggested by ChuckBing and renamed it CleanCBpgnPad.
    Presently this won't compile! (not surprising).
    I copy the code here:
    //CleanCBpgnPad by tR2 based on NutPad text editor
    // editor/NutPad.java -- A very simple text editor -- Fred Swartz - 2004-08
    // Illustrates use of AbstractActions for menus.
    //http://www.roseindia.net/java/java-tips/45examples/20components/editor/nutpad.shtml
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    public class CleanCBpgnPad extends JFrame {
    //-- Components
    private JTextArea mEditArea;
    private JFileChooser mFileChooser = new JFileChooser(".");
    //-- Actions
    private Action mOpenAction;
    private Action mSaveAction;
    private Action mExitAction;
    private Action mCleanAction;
    //===================================================================== main
    public static void main(String[] args) {
    new CleanCBpgnPad().setVisible(true);
    }//end main
    //============================================================== constructor
    public CleanCBpgnPad() {
    createActions();
    this.setContentPane(new contentPanel());
    this.setJMenuBar(createMenuBar());
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setTitle("CleanCBpgnPad");
    this.pack();
    }//end constructor
    ///////////////////////////////////////////////////////// class contentPanel
    private class contentPanel extends JPanel {       
    //========================================================== constructor
    contentPanel() {
    //-- Create components.
    mEditArea = new JTextArea(15, 80);
    mEditArea.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
    mEditArea.setFont(new Font("monospaced", Font.PLAIN, 14));
    JScrollPane scrollingText = new JScrollPane(mEditArea);
    //-- Do layout
    this.setLayout(new BorderLayout());
    this.add(scrollingText, BorderLayout.CENTER);
    }//end constructor
    }//end class contentPanel
    //============================================================ createMenuBar
    /** Utility function to create a menubar. */
    private JMenuBar createMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = menuBar.add(new JMenu("File"));
    fileMenu.add(mOpenAction); // Note use of actions, not text.
    fileMenu.add(mSaveAction);
    fileMenu.add(mCleanAction);
    fileMenu.addSeparator();
    fileMenu.add(mExitAction);
    return menuBar;
    }//end createMenuBar
    //============================================================ createActions
    /** Utility function to define actions. */
    private void createActions() {
    mOpenAction = new AbstractAction("Open...") {
    public void actionPerformed(ActionEvent e) {
    int retval = mFileChooser.showOpenDialog(CleanCBpgnPad.this);
    if (retval == JFileChooser.APPROVE_OPTION) {
    File f = mFileChooser.getSelectedFile();
    try {
    FileReader reader = new FileReader(f);
    mEditArea.read(reader, ""); // Use TextComponent read
    } catch (IOException ioex) {
    System.out.println(e);
    System.exit(1);
    mSaveAction = new AbstractAction("Save") {
    public void actionPerformed(ActionEvent e) {
    int retval = mFileChooser.showSaveDialog(CleanCBpgnPad.this);
    if (retval == JFileChooser.APPROVE_OPTION) {
    File f = mFileChooser.getSelectedFile();
    try {
    FileWriter writer = new FileWriter(f);
    mEditArea.write(writer); // Use TextComponent write
    } catch (IOException ioex) {
    System.out.println(e);
    System.exit(1);
    mCleanAction = new AbstractAction ("Clean"){
    public void actionPerformed (ActionEvent e) {
    int retval = mFileChooser.showCleanDialog(CleanCBpgnPad.this);
    if (retval== JFileChooser.APPROVE_OPTION){
    File f = mFileChooser.getSelectedFile();
    try {
    FileCleaner cleaner = new FileCleaner (c);
    mEditArea.clean(cleaner); // Use TextComponent clean
    }catch (IOException ioex){
    String str = "1. e4 {[%emt 0:00:01]} c6 {[%emt 0:00:10]} 2. d4 {[%emt 0:00:03]} d5 {[%emt 0:00:01]} " + "3. e5 {[%emt 0:00:01]} Bf5 {[%emt 0:00:01]} 4. h4 {[%emt 0:00:02]} e6 {[%emt 0:00:02]}";
    str = str.replaceAll("\\{.*?\\}", "");
    System.out.println(str);
    System.exit(1);
    mExitAction = new AbstractAction("Exit") {
    public void actionPerformed(ActionEvent e) {
    System.exit(0);
    }//end createActions
    }//end class CleanCBpgnPad
    As seen I added a newAction mClean.
    4 errors arise starting with line 101-cannot find symbol method showCleanDialog
    then 3 errors on line 104 tryfilecleaner
    Can anyone help me with this please?
    Can I incorporate the regular expression code to remove these text comments into this text editor code and if so how?
    Obviously a lot of this code is new to me and I will continue to study it and hope to learn to understand most , if not all of it!
    Again I look forward to replies,thanks

  • Help with program flow and timing a loop please

    I'm working on an application that will display vibration data on several tabs.  1 tab displays the time waveform, another a running RMS value, another an FFT etc.
    On another tab I want the user to have the option of streaming the data to disk for 'x' number of seconds.
    I created a sub-vi with a flat sequence structure.
    The first frame open/creates a file.  The second frame gets the current time in seconds and adds 'x' seconds to it.  The third frame  contains a while loop with a "Get Current Time in Seconds" and a  "Write to Binary File" which executes while the current time is less than the "previous current time plus 'x'".
    This sub-vi is in a while loop that is called when a "capture data" button is pressed.
    My problem is that the rest of the program (waveform, RMS, FFT displays) stops executing when the while loop / sub-vi is executing.
    This can be seen via the "TEST" indicator that doesn't update.
    When the program flow goes back to the rest of the program I get an error 'cause the buffer has over-flown (ed)
    I'm really new at this so any help is greatly appreciated.
    I've attached images of the main vi (Project3.pdf) and the sub-vi containing the Flat Sequence (WriteToDisk.pdf)
    I can attach the actual vis if it helps.
    Thanks,
    Erik
    Attachments:
    Project3.pdf ‏189 KB
    WriteToDisk.pdf ‏85 KB

    The behavior you're seeing is by design. There are two solutions to your problem:
    Place the write to file in a separate loop that runs in parallel to your main loop. Thus, your "Project3" VI would have two loops. One is the data acquisition, the other is the streaming to file. You should not create data dependencies between the loops that would cause one loop to wait until the other is done. You want both running in parallel. You can stop both loops with the same stop button. With this method you can use local variables to get the Time Waveform data as you're doing now.
    Launch the stream to file VI dynamically. This basically uses the VI Server to start a subVI and then immediately return to the caller. The subVI is then running on its own. There are examples that ship with LabVIEW that show you how to do this. You would have to have the subVI monitor something to determine if it should stop should the main program stop.
    The first option would be the easiest to implement in your case. The second is more complex, but leaves you with one loop.

  • Help with program plz (long code)

    anyone know how i can fix these 2 errors:
    Driver2.java:47: code is already defined in main(java.lang.String[])
    String code = JOptionPane.showInputDialog(
    ^
    Driver2.java:51: incompatible types
    found : java.lang.String
    required: int
    int val = bc.getCode();
    ^
    the case 2 in the driver is where it messes up, i believe..it works with just the case 1...any help/advice is appreciated(i am aware of spacing errors)
    import javax.swing.JOptionPane;
    import java.util.Scanner;
    public class Driver2
       public static void main(String[] args)
          String userChoice;
          int choice;
    Scanner keyboard = new Scanner(System.in);
    userChoice = JOptionPane.showInputDialog("Enter 1 to enter a numeric zip code:\n"
    + "Enter 2 to enter a bar code:\n"
    + "Enter 3 to exit program:\n");
    choice = Integer.parseInt(userChoice);
    while (choice != 3)
           switch (choice)
           case 1:
           String input = JOptionPane.showInputDialog( "Please enter a five-digit zip code: ");
    int num = Integer.parseInt(input);
    BarCode bc = new BarCode(num);
    String code = bc.getCode();
    JOptionPane.showMessageDialog(null, "The barcode of the zip is: " + code);
    System.exit(0);
    break;
    case 2:
    String code = JOptionPane.showInputDialog( "Please enter bar code: ");
    int val = bc.getCode();
    if (val >= 0)
    System.out.println("The zip code is: " + val);
    else
    System.out.println("Incorrect bar code data");
    System.exit(0);
    break;
    case 3:
    break;
    userChoice = JOptionPane.showInputDialog("Enter 1 to enter a numeric zip code:\n"
    + "Enter 2 to enter a bar code:\n"
    + "Enter 3 to exit program:\n");
       public BarCode(int n)
          zip = n;
       public String getCode()
          String barCode = "|";
          int sum = 0;
          int temp = 0;
          temp = zip / 10000;
          sum = sum + temp;
          Digit d1 = new Digit(temp);
          barCode = barCode + d1.getCode();
          zip = zip % 10000;
          temp = zip / 1000;
          sum = sum + temp;
          Digit d2 = new Digit(temp);
          barCode = barCode + d2.getCode();
          zip = zip % 1000;
          temp = zip / 100;
          sum = sum + temp;
          Digit d3 = new Digit(temp);
          barCode = barCode + d3.getCode();
          zip = zip % 100;
          temp = zip / 10;
          sum = sum + temp;
          Digit d4 = new Digit(temp);
          barCode = barCode + d4.getCode();
          zip = zip % 10;
          temp = zip;
          sum = sum + temp;
          Digit d5 = new Digit(temp);
          barCode = barCode + d5.getCode();
          temp = 10 - (sum % 10);
          Digit d6 = new Digit(temp);
          barCode = barCode + d6.getCode() + "|";
          return barCode;
       private int zip;
    public class BarCode1
       public BarCode1(int n)
          zip = n;
       public String getCode()
          String barCode = "|";
          int sum = 0;
          int temp = 0;
          temp = zip / 10000;
          sum = sum + temp;
          Digit d1 = new Digit(temp);
          barCode = barCode + d1.getCode();
          zip = zip % 10000;
          temp = zip / 1000;
          sum = sum + temp;
          Digit d2 = new Digit(temp);
          barCode = barCode + d2.getCode();
          zip = zip % 1000;
          temp = zip / 100;
          sum = sum + temp;
          Digit d3 = new Digit(temp);
          barCode = barCode + d3.getCode();
          zip = zip % 100;
          temp = zip / 10;
          sum = sum + temp;
          Digit d4 = new Digit(temp);
          barCode = barCode + d4.getCode();
          zip = zip % 10;
          temp = zip;
          sum = sum + temp;
          Digit d5 = new Digit(temp);
          barCode = barCode + d5.getCode();
          temp = 10 - (sum % 10);
          Digit d6 = new Digit(temp);
          barCode = barCode + d6.getCode() + "|";
          return barCode;
       private int zip;
    public class Digit
       public Digit(int n)
          zip = n;
       public String getCode()
          String bar = "";
          if (zip == 1)
             bar = ":::||";
          else if (zip == 2)
             bar = "::|:|";
          else if (zip == 3)
             bar = "::||:";
          else if (zip == 4)
             bar = ":|::|";
          else if (zip == 5)
             bar = ":|:|:";
          else if (zip == 6)
             bar = ":||::";
          else if (zip == 7)
             bar = "|:::|";
          else if (zip == 8)
             bar = "|::|:";
          else if (zip == 9)
             bar = "|:|::";
          else
             bar = "||:::";
          return bar;
       private int zip;
    public class Digit1
       public Digit1(int n)
          zip = n;
       public String getCode()
          String bar = "";
          if (zip == 1)
             bar = ":::||";
          else if (zip == 2)
             bar = "::|:|";
          else if (zip == 3)
             bar = "::||:";
          else if (zip == 4)
             bar = ":|::|";
          else if (zip == 5)
             bar = ":|:|:";
          else if (zip == 6)
             bar = ":||::";
          else if (zip == 7)
             bar = "|:::|";
          else if (zip == 8)
             bar = "|::|:";
          else if (zip == 9)
             bar = "|:|::";
          else
             bar = "||:::";
          return bar;
       private int zip;
    }

    > i got it to compile now...i can toy around w/
    it..thanks for the help
    Good.
    Stick with this handle, ok?I must say I am not thrilled with
    a) when I questioned the first post of WhiteSox asking if it was bugz or a classmate or what I was ignored by the OP
    b) I guess the OP is trying to distance himself from his very first thread where somebody did part of his homework for him with results that are now plainly evident. As I predicted at the end of the last thread.
    http://forum.java.sun.com/thread.jspa?threadID=703258 Reply 11
    I hope that matsabigman and others who help homework posters by doing it for them will take note of the results of this help thus far. Not much good has come of this.
    BigMan/WhiteSox I am still detecting a fundamental lack of basic concepts on your part. This is the underlying cause of your compile errors but those are only a symptom. You can continue treating the symptoms but it would be a better use of your time to treat the disease, which in this case means spending some time getting a better grasp of Java fundamentals.

  • Help with program! (Beginner)

    Here is what I'm trying to do:
    lo : Smallest. Write a program that allows a user to enter a series of positive integers with a -99 to signal the end of the series. The program should then display the smallest of the numbers in the series. Do not use a bogus value for the smallest to begin the program. Use the first value in the data list (if any) to initialize your smallest. This program must have only one programmer-defined method other than main which outputs user directions to the console about how the program works (and that -99 is to be used to end the input). Note that an empty list is possible and should not confuse your program! After displaying directions to the console, use GUI for the remaining input and output. Try out your program on the following lists:
    10, 3, 8, 2, -99 (lo = 2)
    -99 (ouput should be: "no numbers, no lo")
    4, 6, 1, 106, 22, -99 (lo = 1)
    So far, I've established that...
    loop, probably do/while
    get input from user, input
    if input != "-99",
    set list[i] (array) = input
    if input == "-99"
    set list[i] = input (makes it easy to terminate your loop through the array and to tell if it is otherwise emtpy)
    sort through array, comparing two elements of the array, keep lowest and compare to next available, till -99 found
    print as necessary
    - This is what my friend has told me so far, but I'm not sure what he means by 'set list[i] (array) = unput.
    Please help! Either respond here or my screen name (AIM) is Bionix12

    Here's what I've got so far:
    import javax.swing.JOptionPane;
    public class IO {
         public static void main(String[]args){
              String dataString =
              JOptionPane.showInputDialog(null,
              "Enter an int value",
              "IO",
              JOptionPane.QUESTION_MESSAGE);
              int data = Integer.parseInt(dataString);
              int min = data;          
              do {
                   dataString = JOptionPane.showInputDialog(null,
                   "Enter an int value: \n (the program exits if the input is -99)",
                   "IO",
                   JOptionPane.QUESTION_MESSAGE);
                   data = Integer.parseInt(dataString);
                        if (data != -99 && data > min){
                        min = data
              while (number != -99) {
                   JOptionPane.showMessageDialog(null,
                   "The min value is " + data,
                   "IO",
                   JOptionPane.INFORMATION_MESSAGE);
    }

  • Help with program hw

    For my intro to programming class I have this program where i have to take 5 names put them in an array, assign 25 scores (given) to a 1d array named temp and move to an array that is 2d with each 5 scores going to a new line (person). Then you must create a function to compute row & column total, high, low, and average. The average drops the lowest grade and doubling the final exam. Then you must create a function to assign a grade letter in a char array. Then call a "drawGraph" function that prints a bar chart for each person that shows their averages. Then print the results in a frame windwo and then call a function that prints the other arrays in table form (with headings).
    I know this is a long post but I cannot get this thing to run and i have typed almost all the code, so any help would be greatly appreciated! This is what i have so far:
    import java.io.*;
    import javax.swing.*;
    import java.net.*;
    import java.awt.event.*;
    import java.awt.*;
    public class Application1
    public static void main()
    JTextArea dataout= new JTextArea(400,50);
    Frame df = new Frame("application frame");
    df.setSize(800,500);
    Graphics g = df.getGraphics();
    int temp[]={34,24,78,65,45,100,90,97,56,89,78,98,74,90,98,24,45,76,89,54,12,20,22,55,66};
    int scores[][]=new int[8][8];
    float[]avg=new float[5];
    String name[]={"Mary","John","William","Debbie","Ralph"};
    String out=" ";
    char grade[]=new char[5];
    int c=0;
    int d=0;
    int e=0;
    for (int a=0;a<5;a++)
    for(int b=0;b<5;b++)
    scores[a]=temp[c];
    c++;
    scores[a][6]=200;
    scores[6][a]=200;
    finishscoresarray(scores);
    getAverage(scores,avg,grade);
    prntGraph(g,avg,name);
    prntData(avg,name,grade,scores,out);
    dataout.setText(out);
    JOptionPane.showMessageDialog(null,out);
    public static void finishscoresarray(int[][]scores)
    for(int a=0;a<5;a++)
    for(int b=0;b<5;b++)
    scores[5][a]=scores[5][a]+scores[b][a];
    scores[a][5]=scores[a][5]+scores[a][b];
    if(scores[a][b]<scores[6][a])
    scores[6][a]=scores[a][b];
    if(scores[b][a]<scores[a][6])
    scores[a][6]=scores[b][a];
    if(scores[a][b]>scores[7][a])
    scores[7][a]=scores[a][b];
    if(scores[b][a]>scores[a][7])
    scores[a][7]=scores[b][a];
    public static void getAverage(int[][]score, float[]avg, char[]grade)
    for(int a=0;a<5;a++)
    avg[a]=((score[a][5]-score[a][6]+score[a][4])/5);
    if(avg[a]>89)
    grade[a]='A';
    else if(avg[a]>79)
    grade[a]='B';
    else if(avg[a]>69)
    grade[a]='C';
    else if(avg[a]>59)
    grade[a]='D';
    else
    grade[a]='F';
    public static void prntGraph(Graphics g, float[]avg, String[]name)
    for(int a=0;a<5;a++)
    g.drawString(name[a],(int)100*(a+1),100);
    g.drawRect(80*(a+1),80*(a+1),(int)avg[a],40);
    public static void prntData(float[]avg,String[]name,char[]grade,int[][]scores,String out)
    for(int a=0;a<7;a++)
    out=out+name[a]+" "+scores[0][a]+" "+scores[1][a]+" "+scores[2][a]+" "+scores[3][a]+" "+scores[4][a]+" "+scores[5][a]+" "+scores[6][a]+" "+scores[7][a]+" "+avg[a]+" "+grade[a]+"\n";
    Thanks!

    but I cannot get this thing to runexplain what it is you expect to happen
    e.g.
    do you enter some numbers and the output is wrong
    does it not compile/run
    also, so that people can read the code, repost it, but use the code tags to preserve the formatting
    ie click on the code button, which will produce
    [code][/code]
    and paste your code between the two tags

  • Need help with Program Please!

    // Name: John Weir 02/03/2006
    Please read the comments as they will explain what help I need.
    All help greatly appreciated! Am new to working with GUI.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class FeverDiagnosis extends JFrame
         // diagnoisis constants
         private final String MENIGITIS = "menigitis";
         private final String DIGESTIVE_TRACT_INFECTION = "digestive tract infection";
         private final String PNEUMONIA_OR_AIRWAYS_INFECTION  ="pneumonia or airways infection";
         private final String VIRAL_INFECTION = "viral infection";
         private final String THROAT_INFECTION = "throat infection";
         private final String KIDNEY_INFECTION = "kidney infection";
         private final String URINARY_INFECTION = "urinary tract infection";
         private final String SUNSTROKE_OR_HEAT_EXHAUSTION = "sunstroke or heat exhaustion";
         // symptom constants
         private final String FEVER = "fever";
         private final String COUGHING = "coughing";
         private final String HEADACHE = "headache";
         private final String BREATHING_WITH_DIFFICULTY = "shortness of breath, wheezing, or coughing up phlegm";
         private final String ACHING_BONES_JOINTS = "aching bones or joints";
         private final String RASH = "rash";
         private final String SORE_THROAT = "sore throat";
         private final String BACK_PAIN_AND_CHILLS_AND_FEVER = "back pain just above the waist with chills and fever";
         private final String URINARY_DIFFICULTY = "pain urinating or are urinating more often";
         private final String TOO_MUCH_SUN = "sun overexposure due to spending the day in the sun or in hot conditions";
         public final String VOMITING_OR_DIARRHEA = "vomitting spell or diarrhea";
         private final String MENIGITIS_POSSIBILITIES =
                          "pain when bending your head forward,\n"
                        + "    nausea or vomiting, eye ache from \n"
                        + "    bright lights, drowsiness or confusion";
         // GUI varibles
         private JTextArea textArea;
         private JFrame theFrame;
         private JLabel stuff2;
         private JButton b1;
         private JButton b2;
         // instance variable
         private String symptoms = "";
         private Scanner cin = new Scanner (System.in);
         char response;
         String input;
         public FeverDiagnosis()
              JFrame.setDefaultLookAndFeelDecorated(true);
              JFrame theFrame = new JFrame("John Weir");
              theFrame.setSize(650, 400);
              Dimension frameSize = theFrame.getSize();
              Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
              theFrame.setLocation((screenSize.width - frameSize.width)/2,(screenSize.height - frameSize.height)/2);
              theFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              Container contentPane = theFrame.getContentPane();
              theFrame.getContentPane().setLayout(new FlowLayout());
              JLabel stuff2 = new JLabel("Test");
              textArea = new JTextArea(12,50);
              textArea.setEditable(true);
              textArea.setBackground(Color.black);
              textArea.setForeground(Color.green);
              textArea.setFont(new Font("Serif", Font.ITALIC, 16));
              textArea.setLineWrap(true);
              textArea.setWrapStyleWord(true);
              b1 = new JButton("Yes");
              b2 = new JButton("No");
              contentPane.add(stuff2);
              contentPane.add(new JScrollPane(textArea));
              contentPane.add(b1);
              b1.setEnabled(true);
              contentPane.add(b2);
              b2.setEnabled(true);
              ActionListener l = new ActionListener()
                public void actionPerformed(ActionEvent e)
                   if((e.getSource() == b1))
                   //   HELP NEEDED
                   //   NEED BUTTON TO PASS
                   //   STRING VALUE "Y" TO
                   //   METHOD: have(String s)
                   input.equals("y");
                   else
                   if((e.getSource() == b2))
              b1.addActionListener(l);
              b2.addActionListener(l);
              theFrame.setVisible(true);
              theRules();
    public void theRules()
         displayNote();
         if (! have(FEVER) )
              displayUnsure();
         else
         if(are(COUGHING))
              if( are(BREATHING_WITH_DIFFICULTY))
                   addSymptom( PNEUMONIA_OR_AIRWAYS_INFECTION );
                   displayDiagnosis(PNEUMONIA_OR_AIRWAYS_INFECTION);
              }else
              if(have(HEADACHE))
                   addSymptom( VIRAL_INFECTION );
                   displayDiagnosis(VIRAL_INFECTION);
              }else
              if(have(ACHING_BONES_JOINTS))
                   addSymptom( VIRAL_INFECTION );
                   displayDiagnosis(VIRAL_INFECTION);
              }else
              if(have(RASH))
                   displayUnsure();
              }else
              if(have(SORE_THROAT))
                   addSymptom( THROAT_INFECTION );
                   displayDiagnosis(THROAT_INFECTION);
              }else
              if(have(BACK_PAIN_AND_CHILLS_AND_FEVER))
                   addSymptom( KIDNEY_INFECTION );
                   displayDiagnosis(KIDNEY_INFECTION);
              }else
              if(have(URINARY_DIFFICULTY))
                   addSymptom( URINARY_INFECTION );
                   displayDiagnosis(URINARY_INFECTION);
              }else
              if(have(TOO_MUCH_SUN))
                   addSymptom( SUNSTROKE_OR_HEAT_EXHAUSTION );
                   displayDiagnosis(SUNSTROKE_OR_HEAT_EXHAUSTION);
              }else
                   displayUnsure();
              else
              if(have(HEADACHE))
                   addSymptom(VIRAL_INFECTION);
                   displayDiagnosis(VIRAL_INFECTION);
              }else
              if(are(MENIGITIS_POSSIBILITIES))
                   addSymptom( MENIGITIS );
                   displayDiagnosis(MENIGITIS);
              }else
              if(are(VOMITING_OR_DIARRHEA))
                   addSymptom( DIGESTIVE_TRACT_INFECTION );
                   displayDiagnosis(DIGESTIVE_TRACT_INFECTION);
              }else
              displayUnsure();
         public void displayNote()
              textArea.append("\n\n"
                   + "Fever Diagnostic Tool\n"
                   + "---------------------\n\n"
                   + "Please note that this program performs no true diagnostic activity.\n"
                   + "No decisions should be made based upon the tool's analysis. If users\n"
                   + "have a fever, they should contact their doctor.\n\n");
         public boolean have(String s)
              // prompt and extract
              textArea.append("Do you have you " + s + " (y, n): " + "\n");
              // NEED BUTTON TO PASS STRING  FROM ActionPerformed
              // AND HAVE IT RETURNED AS A CHAR RESPONCE!
              input = cin.nextLine();
              response = (char) Character.toLowerCase(input.charAt(0));
              while ( (response != 'y') && (response != 'n') )
                   textArea.append("Are you " + s + " (y, n): " + "\n");
                   input = cin.nextLine();
                   response = (char) Character.toLowerCase(input.charAt(0));
              textArea.append("");
              return response == 'y';
         private boolean are(String s)
              textArea.append("Are you " + s + " (y, n): " + "\n");
              input = cin.nextLine();
              char response = (char) Character.toLowerCase(input.charAt(0));
              while ( (response != 'y') && (response != 'n') )
                   textArea.append("Are you " + s + " (y, n): " + "\n");
                   input = cin.nextLine();
                   response = (char) Character.toLowerCase(input.charAt(0));
              textArea.append("");
              return response == 'y';
         public void addSymptom(String s)
              symptoms += "*   " + s + "\n";
         public void displayDiagnosis(String diagnosis)
              textArea.setText("");
              textArea.append("\nSymptoms:\n" + symptoms + "\n" + "Diagnosis"
                   + "\n   Possibilities include " + diagnosis  + "\n");
              textArea.append("\n");
              //System.exit(0);
         public void displayUnsure()
              textArea.append("\nInsufficient information to make a diagnosis" + "\n");
              textArea.append("\n");
              //System.exit(0);
         public static void main(String[] args)
              new FeverDiagnosis();
    }

    If you're looking to use a JTextArea as a console you can use these two classes
    you are free to use and modify these classes but please do not change the package or take credit for it as your own work.
    TextAreaReader.java
    =================
    * Created on Jul 7, 2005 by @author Tom Jacobs
    package tjacobs;
    import java.awt.TextArea;
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    import java.awt.event.TextEvent;
    import java.awt.event.TextListener;
    import java.io.BufferedInputStream;
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.Reader;
    import javax.swing.JFrame;
    import javax.swing.JTextArea;
    public class TextAreaReader extends Reader implements KeyListener {
         JTextArea mJArea;
         TextArea mAWTArea;
         Object mKeyLock = new Object();
         Object mLineLock = new Object();
         String mLastLine;
         int mLastKeyCode = 1;
         public TextAreaReader(JTextArea area) {
              super();
              mJArea = area;
              mJArea.addKeyListener(this);
         public TextAreaReader(TextArea area) {
              super();
              mAWTArea = area;
              mAWTArea.addKeyListener(this);
         public void keyPressed(KeyEvent ke) {
              mLastKeyCode = ke.getKeyCode();
              synchronized(mKeyLock) {
                   mKeyLock.notifyAll();
              if (ke.getKeyCode() == KeyEvent.VK_ENTER) {
                   if (mJArea != null) {
                        String txt = mJArea.getText();
                        int idx = txt.lastIndexOf('\n', mJArea.getCaretPosition() - 1);
                        mLastLine = txt.substring(idx != -1 ? idx : 0, mJArea.getCaretPosition());//txt.length());
                        synchronized(mLineLock) {
                             mLineLock.notifyAll();
                   else {
                        String txt = mAWTArea.getText();
                        int idx = txt.lastIndexOf('\n', mAWTArea.getCaretPosition() - 1);
                        mLastLine = txt.substring(idx != -1 ? idx : 0, mAWTArea.getCaretPosition());//txt.length());
                        synchronized(mLineLock) {
                             mLineLock.notifyAll();
         public void keyReleased(KeyEvent ke) {
         public void keyTyped(KeyEvent ke) {
         public int read(char[] arg0, int arg1, int arg2) throws IOException {
              throw new IOException("Not supported");
         public String readLine() {
              synchronized(mLineLock) {
                   try {
                        mLineLock.wait();
                   catch (InterruptedException ex) {
              return mLastLine;
         public int read() {
              synchronized(mKeyLock) {
                   try {
                        mKeyLock.wait();
                   catch (InterruptedException ex) {
              return mLastKeyCode;
         public void close() throws IOException {
              // TODO Auto-generated method stub
         public static void main(String args[]) {
              JFrame f = new JFrame("TextAreaInput Test");
              JTextArea area = new JTextArea();
              final TextAreaReader tar = new TextAreaReader(area);
              f.add(area);
              Runnable r1 = new Runnable() {
                   public void run() {
                        while (true) {
                             int code = tar.read();
                             System.out.println("read: " + code);
              Runnable r2 = new Runnable() {
                   public void run() {
                        while (true) {
                             String line = tar.readLine();
                             System.out.println("read line: " + line);
              Thread t1 = new Thread(r1);
              Thread t2 = new Thread(r2);
              t1.start();
              t2.start();
              f.setBounds(100, 100, 200, 200);
              f.setVisible(true);
         public InputStream toInputStream() {
              return new MyInputStream();
         private class MyInputStream extends InputStream {
              public int read() {
                   return TextAreaReader.this.read();
    ==================
    TextAreaOutputStream
    ==================
    * Created on Mar 13, 2005 by @author Tom Jacobs
    package tjacobs;
    import java.io.IOException;
    import java.io.OutputStream;
    import javax.swing.JTextArea;
    import javax.swing.text.JTextComponent;
    public class TextAreaOutputStream extends OutputStream {
         public static final int DEFAULT_BUFFER_SIZE = 1;
         JTextArea mText;
         byte mBuf[];
         int mLocation;
         public TextAreaOutputStream(JTextArea component) {
              this(component, DEFAULT_BUFFER_SIZE);
         public TextAreaOutputStream(JTextArea component, int bufferSize) {
              mText = component;
              if (bufferSize < 1) bufferSize = 1;
              mBuf = new byte[bufferSize];
              mLocation = 0;
         @Override
         public void write(int arg0) throws IOException {
              //System.err.println("arg = "  + (char) arg0);
              mBuf[mLocation++] = (byte)arg0;
              if (mLocation == mBuf.length) {
                   flush();
         public void flush() {
              mText.append(new String(mBuf, 0, mLocation));
              mLocation = 0;
              try {
                   Thread.sleep(1);
              catch (Exception ex) {}
    }

  • I need help with programs from my MacBookAir.

    Hello. I've intalled programs on my MacbookAit that I don't need anymore and I have no idea how to remove them from my laptop. I've been a PC user and I knew there how to remove them but here I just don't know. I know that dragging them to the trash won't work. I want to remove them and free the space that is taking. I hope you guys can help me with this. Thank you Very Much!!!

    Uninstalling Software: The Basics
    Most OS X applications are completely self-contained "packages" that can be uninstalled by simply dragging the application to the Trash.  Applications may create preference files that are stored in the /Home/Library/Preferences/ folder.  Although they do nothing once you delete the associated application, they do take up some disk space.  If you want you can look for them in the above location and delete them, too.
    Some applications may install an uninstaller program that can be used to remove the application.  In some cases the uninstaller may be part of the application's installer, and is invoked by clicking on a Customize button that will appear during the install process.
    Some applications may install components in the /Home/Library/Applications Support/ folder.  You can also check there to see if the application has created a folder.  You can also delete the folder that's in the Applications Support folder.  Again, they don't do anything but take up disk space once the application is trashed.
    Some applications may install a startupitem or a Log In item.  Startupitems are usually installed in the /Library/StartupItems/ folder and less often in the /Home/Library/StartupItems/ folder.  Log In Items are set in the Accounts preferences.  Open System Preferences, click on the Accounts icon, then click on the LogIn Items tab.  Locate the item in the list for the application you want to remove and click on the "-" button to delete it from the list.
    Some software use startup daemons or agents that are a new feature of the OS.  Look for them in /Library/LaunchAgents/ and /Library/LaunchDaemons/ or in /Home/Library/LaunchAgents/.
    If an application installs any other files the best way to track them down is to do a Finder search using the application name or the developer name as the search term.  Unfortunately Spotlight will not look in certain folders by default.  You can modify Spotlight's behavior or use a third-party search utility, Easy Find, instead.  Download Easy Find at VersionTracker or MacUpdate.
    Some applications install a receipt in the /Library/Receipts/ folder.  Usually with the same name as the program or the developer.  The item generally has a ".pkg" extension.  Be sure you also delete this item as some programs use it to determine if it's already installed.
    There are many utilities that can uninstall applications.  Here is a selection:
    AppZapper 2.0.1
    AppDelete 3.2.6
    Automaton 1.50
    Hazel
    AppCleaner 2.1.0
    CleanApp
    iTrash 1.8.2
    Amnesia
    Uninstaller 1.15.1
    Spring Cleaning 11.0.1
    Look for them at VersionTracker or MacUpdate.
    For more information visit The XLab FAQs and read the FAQ on removing software.

  • Need a little help with program (long code)

    Jist of program: If User enters a zip code, convert it to bar code. If User enters a bar code, convert it to zip code. Below is the code for the classes. Question is how to get the constructors under the same class to where they can compile. I'm not sure what to do...Any help is definately appreciated
    public class BarCode
       public BarCode(int n)
          zip = n;
       public String getCode()
          String barCode = "|";
          int sum = 0;
          int temp = 0;
          temp = zip / 10000;
          sum = sum + temp;
          Digit d1 = new Digit(temp);
          barCode = barCode + d1.getCode();
          zip = zip % 10000;
          temp = zip / 1000;
          sum = sum + temp;
          Digit d2 = new Digit(temp);
          barCode = barCode + d2.getCode();
          zip = zip % 1000;
          temp = zip / 100;
          sum = sum + temp;
          Digit d3 = new Digit(temp);
          barCode = barCode + d3.getCode();
          zip = zip % 100;
          temp = zip / 10;
          sum = sum + temp;
          Digit d4 = new Digit(temp);
          barCode = barCode + d4.getCode();
          zip = zip % 10;
          temp = zip;
          sum = sum + temp;
          Digit d5 = new Digit(temp);
          barCode = barCode + d5.getCode();
          temp = 10 - (sum % 10);
          Digit d6 = new Digit(temp);
          barCode = barCode + d6.getCode() + "|";
          return barCode;
       private int zip;
    public BarCode(String aCode)
          code = aCode;
       public int getCode()
          if (code.length() != 2 + 6 * DIGITLENGTH)
            return -1;
          if (!code.substring(0, 1).equals("|"))
             return -1;
          int i = 1;
          int sum = 0;
          int dsum = 0;
          String codeDigit = code.substring(i, i + DIGITLENGTH);
          Digit d1 = new Digit(codeDigit);
          int val = d1.getCode();
          i = i + DIGITLENGTH;
          if (val < 0)
             return -1;
          sum = sum + val * 10000;
          dsum = dsum + val;
          codeDigit = code.substring(i, i + DIGITLENGTH);
          Digit d2 = new Digit(codeDigit);
          val = d2.getCode();
          i = i + DIGITLENGTH;
          if (val < 0)
             return -1;
          sum = sum + val * 1000;
          dsum = dsum + val;
          codeDigit = code.substring(i, i + DIGITLENGTH);
          Digit d3 = new Digit(codeDigit);
          val = d3.getCode();
          i = i + DIGITLENGTH;
          if (val < 0)
             return -1;
          sum = sum + val * 100;
          dsum = dsum + val;
          codeDigit = code.substring(i, i + DIGITLENGTH);
          Digit d4 = new Digit(codeDigit);
          val = d4.getCode();
          i = i + DIGITLENGTH;
          if (val < 0)
             return -1;
          sum = sum + val * 10;
          dsum = dsum + val;
          codeDigit = code.substring(i, i + DIGITLENGTH);
          Digit d5 = new Digit(codeDigit);
          val = d5.getCode();
          i = i + DIGITLENGTH;
          if (val < 0)
          return -1;
          sum = sum + val;
          dsum = dsum + val;
          codeDigit = code.substring(i, i + DIGITLENGTH);
          Digit d6 = new Digit(codeDigit);
          val = d6.getCode();
          i = i + DIGITLENGTH;
          if (val < 0)
             return -1;
          dsum = dsum + val;
          if (dsum % 10 != 0)
             return -1;
          if (!code.substring(i, i + 1).equals("|"))
             return -1;
          return sum;
       public boolean isValid()
          return true;
       private final int DIGITLENGTH = 5;
       private String code;
    public class Digit
        public Digit(int n)
          zip = n;
       public String getCode()
          String bar = "";
          if (zip == 1)
             bar = ":::||";
          else if (zip == 2)
             bar = "::|:|";
          else if (zip == 3)
             bar = "::||:";
          else if (zip == 4)
             bar = ":|::|";
          else if (zip == 5)
             bar = ":|:|:";
          else if (zip == 6)
             bar = ":||::";
          else if (zip == 7)
             bar = "|:::|";
          else if (zip == 8)
             bar = "|::|:";
          else if (zip == 9)
             bar = "|:|::";
          else
             bar = "||:::";
          return bar;
       private int zip;
    public Digit(String aCode)
          code = aCode;
       public int getCode()
          if (code.equals(":::||"))
             return 1;
          else if (code.equals("::|:|"))
             return 2;
          else if (code.equals("::||:"))
             return 3;
          else if (code.equals(":|::|"))
             return 4;
          else if (code.equals(":|:|:"))
             return 5;
          else if (code.equals(":||::"))
             return 6;
          else if (code.equals("|:::|"))
             return 7;
          else if (code.equals("|::|:"))
             return 8;
          else if (code.equals("|:|::"))
             return 9;
          else if (code.equals("||:::"))
             return 0;
          else return -1;
       public boolean isValid()
          return false;
       private String code;
    }

    Your squiggly braces are completely out of whack!
    Class definitions should be something like this:class ClassName
        public ClassName()    // one constructor
            // code here
        public ClassName(String someString)    // another constructor
            // code here
        public void someMethod()
            // code here
    class AnotherClass
        public void anotherMethod()
            // code here
    }For each opening curly brace { there must be exactly one closing curly brace }.
    Once you've gotten your curly braced figured out, you can deal with the multiple redefinitions of your methods. One step at a time, though.

  • Help with programming exercise

    This is my assignment:
    Exercise 36 � Computation
    Write a program that computes the following sum:
    sum = 1.0/1 + 1.0/2 + 1.0/3 + 1.0/4 + 1.0/5 + .... + 1.0/N
    N will be an integer limit that the user enters.
    Enter N
    4
    Sum is: 2.08333333333
    And this is what I have so far:
    import learning.*;
    class Computation
    public static void main(String[] args)
    int N;
    double Sum;
    System.out.println("Enter N");
    N = LearningIO.readInt();
    Sum = 1.0/N;
    for ( N= 1; <=N ; Sum++)
    System.out.println(Sum);
    I don't know what to use for the termination process. Any help will be appreciated.

    My suggestion to to sit down do a few examples, then try to execute your code by hand. For example, If I imagine the user enters 4 for N,
    You initialize Sum to be 1/4. You need to compute the summation 1/1 + 1/2 + 1/3 + 1/4. There are two obvious ways to do this: right-to-left:
    1/4
    1/3 + 1/4
    1/2 + 1/3 + 1/4
    1/1 + 1/2 + 1/3 + 1/4
    or left-to-right. Since you are starting with SUM = 1/4, I assume you want to do it right-to-left. But look at your loop:
    for ( N= 1; <=N ; Sum++)
    There are several things wrong: N is your upper bound and it would simplify things to think of it as a constant -- don't assign 1 to it. Second, you are incrementing Sum -- Sum is not an index. You should be adding fractions to Sum. What's missing here is an loop index. introduce another variable to serve as the loop index and everything will fall into place.
    edit: Spoonfeeding isn't helping!
    Edited by: BigDaddyLoveHandles on Nov 20, 2007 8:42 AM

Maybe you are looking for

  • How do I put Snow Leopard on my new SSD?

    Hello. I have been having nothing but problems trying to install a new harddrive in my mid-2009 Macbook pro. I returned my Intel SSD that was apparently not compatible with my computer and just purchased a Crucial M4 256GB SSD. To put it very simply,

  • In elements 5.0 How do I get the icons back onto the organizer photos?

    While taking photos from the organizer to the collections, the icons disappeared from the organizer photos but the pictures all went into the collections...So I can no longer tell which pics in the organizer have already been put into collections...I

  • Horribly slow loading

    Basically my computer takes about a minute to start up and about 5 minutes to run applications.I realize this isn't very specific so here are the facts as I've observed them: 1. The copy of Windows I have runs just fine under the same circumstances,

  • Data modaling issue !!!

    Hey experts ! i need your help. i am lost... I have a query, with variable 0date range. so when the user execute the report, variable windo pops up and ask for a date range., something like this.(.07/05/2007 - 06/12/2008 ) Now, using above date range

  • ITunes requires safari 4.0.3 or later...

    <p style="padding: 0pt; margin: 0pt;" mcestyle="padding: 0pt; margin: 0pt;">iTunes requires safari 4.0.3 or later to be installed to use the iTunes store within iTunes.  That is the message I get.  I just had Leopard 10.5.6 installed ( at the mac sto