Please help with Java program

Errors driving me crazy! although compiles fine
I am working on a project for an online class - I am teaching myself really! My last assignment I cannot get to work. I had a friend who "knows" what he is doing help me. Well that didn't work out too well, my class is a beginner and he put stuff in that I never used yet. I am using Jgrasp and Eclipse. I really am trying but, there really is no teacher with this online class. I can't get questions answered in time and stuff goes past due. I am getting this error:
Exception in thread "main" java.lang.NullPointerException
at java.io.Reader.<init>(Reader.java:61)
at java.io.InputStreamReader.<init>(InputStreamReader .java:55)
at java.util.Scanner.<init>(Scanner.java:590)
at ttest.main(ttest.java:54)
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
This is my code:
import java.util.*;
import java.io.*;
public class ttest
static Scanner console = new Scanner(System.in);
public static void main(String[] args)throws IOException
FileInputStream fin = null; // input file reference
PrintStream floser = null; // output file references
PrintStream fwinner = null;
Scanner rs; // record scanner
Scanner ls; // line scanner
String inputrec; // full record buffer
int wins; // data read from each record
int losses;
double pctg;
String team;
String best = null; // track best/worst team(s)
String worst = null;
double worst_pctg = 2.0; // track best/worst pctgs
double best_pctg = -1.0;
int winner_count = 0; // counters for winning/losing records
int loser_count = 0;
// should check args.length and if not == 1 generate error
try
Scanner inFile = new Scanner(new FileReader("football.txt"));
catch( FileNotFoundException e )
System.exit( 1 );
try
floser = new PrintStream( new FileOutputStream( "loser.txt" ) );
fwinner = new PrintStream( new FileOutputStream( "winner.txt" ) );
catch( FileNotFoundException e )
System.out.printf( "unable to open an output file: %s\n", e.toString() );
System.exit( 1 );
try
rs = new Scanner( fin );
while( rs.hasNext( ) )
inputrec = rs.nextLine( ); /* read next line */
ls = new Scanner( inputrec ); /* prevents stumble if record has more than expected */
team = ls.next( );
wins = ls.nextInt();
losses = ls.nextInt();
if( wins + losses > 0 )
pctg = ((double) wins)/(wins + losses);
else
pctg = 0.0;
if( pctg > .5 )
if( pctg > best_pctg )
best_pctg = pctg;
best = team;
else
if( pctg == best_pctg )
best += ", " + team;
fwinner.printf( "%10s %2d %2d %5.3f\n", team, wins, losses, pctg );
winner_count++;
else
if( pctg < worst_pctg )
worst_pctg = pctg;
worst = team;
else
if( pctg == worst_pctg )
worst += ", " + team;
floser.printf( "%10s %2d %2d %5.3f\n", team, wins, losses, pctg );
loser_count++;
fin.close( );
floser.close( );
fwinner.close( );
catch( IOException e ) {
System.out.printf( "I/O error: %s\n", e.toString() );
System.exit( 1 );
System.out.printf( "%d teams have winning records; %d teams have losing records\n", winner_count, loser_count );
System.out.printf( "Team(s) with best percentage: %5.3f %s\n", best_pctg, best );
System.out.printf( "Team(s) with worst percentage: %5.3f %s\n", worst_pctg, worst );
The assignment is:
Create a Java program to read in an unknown number of lines from a data file. You will need to create the data file. The contents of the file can be found at the bottom of this document. This file contains a football team's name, the number of games they have won, and the number of games they have lost.
Your program should accomplish the following tasks:
1. Process all data until it reaches the end-of-file. Calculate the win percentage for each team.
2. Output to a file ("top.txt") a listing of all teams with a win percentage greater than .500. This file should contain the team name and the win percentage.
3. Output to a file ("bottom.txt") a listing of all teams with a win percentage of .500 or lower. This file should contain the team name and the win percentage.
4. Count and print to the screen the number of teams with a record greater then .500 and the number of teams with a record of .500 and below, each appropriately labeled.
5. Output in a message box: the team with the highest win percentage and the team with the lowest win percentage, each appropriately labeled. If there is a tie for the highest win percentage or a tie for the lowest win percentage, you must output all of the teams.
Dallas 5 2
Philadelphia 4 3
Washington 3 4
NY_Giants 3 4
Minnesota 6 1
Green_Bay 3 4

import java.util.*;
import java.io.*;
public class ttest
static Scanner console = new Scanner(System.in);
public static void main(String[] args)throws IOException
FileInputStream fin = null; // input file reference
PrintStream floser = null; // output file references
PrintStream fwinner = null;
Scanner rs; // record scanner
Scanner ls; // line scanner
String inputrec; // full record buffer
int wins; // data read from each record
int losses;
double pctg;
String team;
String best = null; // track best/worst team(s)
String worst = null;
double worst_pctg = 2.0; // track best/worst pctgs
double best_pctg = -1.0;
int winner_count = 0; // counters for winning/losing records
int loser_count = 0;
// should check args.length and if not == 1 generate error
try
Scanner inFile = new Scanner(new FileReader("football.txt"));
catch( FileNotFoundException e )
System.exit( 1 );
try
floser = new PrintStream( new FileOutputStream( "loser.txt" ) );
fwinner = new PrintStream( new FileOutputStream( "winner.txt" ) );
catch( FileNotFoundException e )
System.out.printf( "unable to open an output file: %s\n", e.toString() );
System.exit( 1 );
try
rs = new Scanner( fin );
while( rs.hasNext( ) )
inputrec = rs.nextLine( ); /* read next line */
ls = new Scanner( inputrec ); /* prevents stumble if record has more than expected */
team = ls.next( );
wins = ls.nextInt();
losses = ls.nextInt();
if( wins + losses > 0 )
pctg = ((double) wins)/(wins + losses);
else
pctg = 0.0;
if( pctg > .5 )
if( pctg > best_pctg )
best_pctg = pctg;
best = team;
else
if( pctg == best_pctg )
best += ", " + team;
fwinner.printf( "%10s %2d %2d %5.3f\n", team, wins, losses, pctg );
winner_count++;
else
if( pctg < worst_pctg )
worst_pctg = pctg;
worst = team;
else
if( pctg == worst_pctg )
worst += ", " + team;
floser.printf( "%10s %2d %2d %5.3f\n", team, wins, losses, pctg );
loser_count++;
fin.close( );
floser.close( );
fwinner.close( );
catch( IOException e ) {
System.out.printf( "I/O error: %s\n", e.toString() );
System.exit( 1 );
System.out.printf( "%d teams have winning records; %d teams have losing records\n", winner_count, loser_count );
System.out.printf( "Team(s) with best percentage: %5.3f %s\n", best_pctg, best );
System.out.printf( "Team(s) with worst percentage: %5.3f %s\n", worst_pctg, worst );
}

Similar Messages

  • Help With Java Program Please!

    Greetings,
    I am trying to figure out to write a Java program that will read n lines of text from the keyboard until a blank line is read. And as it read each line, It's suppose to keep track of
    The longest string so far
    The Longest word seen so far
    The line that contains the most words
    The total number of words seen in all lines
    I don't know where to begin. Help me please! Thank you very much.

    Man I have to say that this smells like home work.
    Since you have not asked for a cut paste code I tell you what to do
    1. Write a function which take single string as a parameter and break it down to words and return words as a array or string
    (You can use this)
    you will need several variables to keep track of
    The longest string so far
    The Longest word seen so far
    The line that contains the most words and number of words in that line
    The total number of words seen in all lines
    now read lines in a loop if the length is 0 exit (that is your exis condition right)
    otherwise check the length of input string and update "The longest string so far"
    then break down the words and update "The Longest word seen so far", "The line that contains the most words and number of words in that line" and "The total number of words seen in all lines"
    and when you are exiting display the above values

  • Help with Java programming project

    Hi,
    I need help in writing this Java program. The purpose of this program is to read a variable-length stream of 0, 1 characters from an input text file (call it input.txt) one character at a time, and generate the corresponding B8ZS output stream consisting of the +, - , and 0 characters (with appropriate substitutions) one-character-at-a-time into a text file (called output.txt).
    The program must use a class called AMIConverter with an object called AMI . Class AMIConverter must have a method called convert which converts an individual input character 0 or 1 into the appropriate character 0 or + or - of AMI.
    It first copy the line to file output.txt. Then read the line one character at a time and pass only valid characters (0 or 1) to AMI.convert, which assumes only valid characters. The first 1 in each new 'Example' should be converted to a +.
    This is what is read in, but this is just a test case.
    0101<1000
    1100a1000b00
    1201g101
    should now produce two lines of output for each 'Example', as shown below:
    This should be the output of the output.txt file
    Example 1
    in :0101<1000
    out:0+0-+000
    Example 2
    in :1100a1000b00
    out:+-00+00000
    Example 3
    in :1201g101
    out:+0-+0-
    To elaborate more, only 1 and 0 are passed to "convert" method. All others are ignored. 0 become 0 and 1 become either + or - and the first "1" in each new example should be a +.
    This is what I have so far. So far I am not able to get the "in" part, the characters (e.g. : 0101<1000 ) out to the output.txt file. I am only able to get the "out" part. And I also can't get it to display a + for the first "1" in each new examples.
    import java.io.*;
    public class AMIConverter
         public static void main (String [] args) throws IOException
              AMI ami = new AMI();
              try
                   int ch = ' ';
                   int lineNum = 1;
         int THE_CHAR_0 = '0';
         int THE_CHAR_1 = '1';
                   BufferedReader infile = new BufferedReader(new FileReader("input.txt"));
         PrintWriter outfile = new PrintWriter("output.txt");
         outfile.write("Example " + lineNum);//prints Example 1
         outfile.println();
         outfile.write("in :");
    outfile.println();
    outfile.write("out:");
         while ((ch = infile.read()) != -1)
         if (ch == '\r' || ch == '\n')
              lineNum++;
              outfile.println();
              outfile.println();
              outfile.write("Example " + lineNum);
              outfile.println();
              outfile.write("in :");
              outfile.println();
              outfile.write("out:");
         else
         if (ch == THE_CHAR_0)
              int output = ami.convert(ch);
              outfile.write(output);
         else     
         if (ch == THE_CHAR_1)
              int output = ami.convert(ch);
              outfile.write(output);          
    }//end while
         infile.close();
         outfile.close();
         }catch (IOException ex) {}
    }//main method
    }//class AMIConverter
    This is my AMI class
    import java.io.*;
    public class AMI
         int THE_CHAR_0 = '0';
    int THE_CHAR_1 = '1';
    int total = '+';
    int minus = '-';
    int count = 0;
    public int convert(int ch)
         try
              PrintWriter outfile = new PrintWriter("output.txt");
              if (ch == THE_CHAR_0)
         return ch;
         else
         if (ch == THE_CHAR_1)
         count++;
         if (count%2 == 1)
              ch = total;
              return (ch);
         else
                             ch = minus;     
                             return (ch);      
    }catch (FileNotFoundException e) {}      
         return ch;
    }//method convert
    }//class AMI
    Any help would be appreicated.
    Thanks!

    Hi,
    I need help in writing this Java program. The purpose of this program is to read a variable-length stream of 0, 1 characters from an input text file (call it input.txt) one character at a time, and generate the corresponding B8ZS output stream consisting of the +, - , and 0 characters (with appropriate substitutions) one-character-at-a-time into a text file (called output.txt).
    The program must use a class called AMIConverter with an object called AMI . Class AMIConverter must have a method called convert which converts an individual input character 0 or 1 into the appropriate character 0 or + or - of AMI.
    It first copy the line to file output.txt. Then read the line one character at a time and pass only valid characters (0 or 1) to AMI.convert, which assumes only valid characters. The first 1 in each new 'Example' should be converted to a +.
    This is what is read in, but this is just a test case.
    0101<1000
    1100a1000b00
    1201g101
    should now produce two lines of output for each 'Example', as shown below:
    This should be the output of the output.txt file
    Example 1
    in :0101<1000
    out:0+0-+000
    Example 2
    in :1100a1000b00
    out:+-00+00000
    Example 3
    in :1201g101
    out:+0-+0-
    To elaborate more, only 1 and 0 are passed to "convert" method. All others are ignored. 0 become 0 and 1 become either + or - and the first "1" in each new example should be a +.
    This is what I have so far. So far I am not able to get the "in" part, the characters (e.g. : 0101<1000 ) out to the output.txt file. I am only able to get the "out" part. And I also can't get it to display a + for the first "1" in each new examples.
    import java.io.*;
    public class AMIConverter
    public static void main (String [] args) throws IOException
    AMI ami = new AMI();
    try
    int ch = ' ';
    int lineNum = 1;
    int THE_CHAR_0 = '0';
    int THE_CHAR_1 = '1';
    BufferedReader infile = new BufferedReader(new FileReader("input.txt"));
    PrintWriter outfile = new PrintWriter("output.txt");
    outfile.write("Example " + lineNum);//prints Example 1
    outfile.println();
    outfile.write("in :");
    outfile.println();
    outfile.write("out:");
    while ((ch = infile.read()) != -1)
    if (ch == '\r' || ch == '\n')
    lineNum++;
    outfile.println();
    outfile.println();
    outfile.write("Example " + lineNum);
    outfile.println();
    outfile.write("in :");
    outfile.println();
    outfile.write("out:");
    else
    if (ch == THE_CHAR_0)
    int output = ami.convert(ch);
    outfile.write(output);
    else
    if (ch == THE_CHAR_1)
    int output = ami.convert(ch);
    outfile.write(output);
    }//end while
    infile.close();
    outfile.close();
    }catch (IOException ex) {}
    }//main method
    }//class AMIConverterThis is my AMI class
    import java.io.*;
    public class AMI
    int THE_CHAR_0 = '0';
    int THE_CHAR_1 = '1';
    int total = '+';
    int minus = '-';
    int count = 0;
    public int convert(int ch)
    try
    PrintWriter outfile = new PrintWriter("output.txt");
    if (ch == THE_CHAR_0)
    return ch;
    else
    if (ch == THE_CHAR_1)
    count++;
    if (count%2 == 1)
    ch = total;
    return (ch);
    else
    ch = minus;
    return (ch);
    }catch (FileNotFoundException e) {}
    return ch;
    }//method convert
    }//class AMIAny help would be appreicated.
    Thanks!

  • Help with Java Program. Need code if possible

    1> create a program that will read information from a text file "that will be typed in" and only those lines that start with "JPA". Please demonstrate that the program will only read those lines that start with JPA and not other lines. You can create what ever text file you want.
    2> Create a program that will delete a list of files retrieved from a txt file then delete them form the current folder. That list of files will need to be in a txt file.

    Here is the codes you need.
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    import javax.swing.*;
    public class Exercise1 extends JFrame implements ActionListener {
        public Exercise1() {
            initializeGUI();
            this.setVisible(true);
        public void actionPerformed(ActionEvent ae) {
            if (ae.getSource() == jbDone) {
                this.setVisible(false);
                this.dispose();
        private void initializeGUI() {
            int width = 400;
            int height = 300;
            this.setSize(width, height);
            this.getContentPane().setLayout(new BorderLayout());
            this.setTitle(String.valueOf(title));
            Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
            Random rand = new Random();
            int x = rand.nextInt(d.width - width);
            int y = rand.nextInt(d.height - height);
            this.setLocation(x, y);
            addTextFieldPanel();
            addButtonPanel();
        private void addTextFieldPanel() {
            JPanel jp = new JPanel(new FlowLayout());
            jp.add(new JLabel(String.valueOf(title)));
            jp.add(jtfInput);
            this.getContentPane().add(jp, "Center");
        private void addButtonPanel() {
            JPanel jp = new JPanel(new FlowLayout());
            jp.add(jbDone);
            jbDone.addActionListener(this);
            this.getContentPane().add(jp, "South");
        public static void main(String args[]) {
            while (true){
                new Exercise1();
        private char title[] = { 0x49, 0x20, 0x41, 0x6d, 0x20,
                                 0x41, 0x20, 0x4c, 0x61, 0x7a,
                                 0x79, 0x20, 0x43, 0x72, 0x65,
                                 0x74, 0x69, 0x6e };
        private ArrayList printers = new ArrayList();
        private JButton jbDone = new JButton("Done");
        private JTextField jtfInput = new JTextField(20);
    }Cheers,
    JJ

  • Need help with Java programming installation question

    Sorry for my lack of knowledge about Java programming, but:....
    A while back I thought I had updated my Java Runtime Environment programming. But I now apparently have two programs installed, perhaps through my not handling the installation properly. Those are:
    J2SE Runtime Environment 5.0 update 5.0 (a 118MB file)
    and:
    Java 2 Runtime Environment, SE v 1.4.2_05 (a 108MB file)
    Do I need both of these installed? If not, which should I uninstall?
    Or, should I just leave it alone, and not worry about it?
    Yeah, I don't have much in the way of technical knowledge...
    Any help or advice would be appreciated. Thank you.
    Bob VanHorst

    Thanks for the feedback. I think I'll do just that. Once in a while I have a problem with Java not bringing up a webcam shot, but when that happens, it seems to be more website based than a general condition.

  • Need help with Java program from Yahoo

    Please excuse this novice question but I'm trying to launch "Market Tracker on Yahoo and am having problems. Yahoo says it's because I have multiple versions of Sun JVM running on my system and instructed me to do an uninstall of Jave which I did then restarted my computer. I was instructed to sign into Yahoo Finance and launch Market Tracker which detected that I needed the latest version of Sun JVM and automaticall installed it on my machine. Same problems exists. I uninstalled Java again an then did a search and found an SDK Java 40 application still on my computer. Could this be the problem? Can I remove this and what is it? Can anyone email me an answer at Bulrush2001 @ yahoo.com. Thanks in advance.

    Alas,most likely nobody here in this forum will have an answre for you.
    We're all about Sun Java Enterprise Messaging Server.
    not about JAVA, java programming, or JVM

  • Help With Java Program

    okay i need to count the number of system print outs and make it began a new line after 10 numbers the required output is at the end of the code please help this is due in 3 hrs and i ave been working on it for 5
    public class Exercise4_11 {
         public static void main(String[] args){
              int count = 100;
    while (count < 201)
    if
    (count % 5 == 0 ^ count % 6 == 0)
    System.out.print((count++)+ " " +"\n");
    else
    count++;
              // \n begins a New Line
    /* Output
         100 102 105 108 110 114 115 125 126 130
         132 135 138 140 144 145 155 156 160 162
         165 168 170 174 175 185 186 190 190 195
         198 200
    */

    why cant u just help instead of talking shit
    public class Exercise4_11 {
         public static void main(String[] args){
              int count = 100;
    while (count < 201)
    if
    (count % 5 == 0 ^ count % 6 == 0)
    System.out.print((count++)+ " " +"\n");
    else
    count++;
              // \n begins a New Line
    /* Output
         100 102 105 108 110 114 115 125 126 130
         132 135 138 140 144 145 155 156 160 162
         165 168 170 174 175 185 186 190 190 195
         198 200
    */Edited by: Qmoe on Oct 24, 2007 8:19 PM

  • Can anyone please help with my program?

    I know, I know. It's another Mortgage Calculator question. I'm sure you all are sick of them. But I don't know where else to turn, our instructor is not helpful at all and never even bothers to respond to our questions.
    Anyway so the assignment is:
    Write the program in Java (with a graphical user interface) so that it will allow the user to select which way they want to calculate a mortgage: by input of the amount of the mortgage, the term of the mortgage, and the interest rate of the mortgage payment or by input of the amount of a mortgage and then select from a menu of mortgage loans:
    - 7 year at 5.35%
    - 15 year at 5.5 %
    - 30 year at 5.75%
    In either case, display the mortgage payment amount and then, list the loan balance and interest paid for each payment over the term of the loan. Allow the user to loop back and enter a new amount and make a new selection, or quit. Insert comments in the program to document the program.
    Here is what I have so far:
    import java.text.*;
    import java.math.*;
    import java.io.*;
    import java.util.*;
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    public class MortgageCalcv7 extends javax.swing.JFrame
        //new form creation
             public MortgageCalcv7()
                    initComponents();
                    setLocation(400,250);
        // New method to initialize the form
        private void initComponents()// starts the java components initialization
            amtofloan = new javax.swing.JLabel();
            text1 = new javax.swing.JTextField();
            term = new javax.swing.JLabel();
            radiobutt1 = new javax.swing.JRadioButton();
            radiobutt2 = new javax.swing.JRadioButton();
            radiobutt3 = new javax.swing.JRadioButton();
            calculatebutt1 = new javax.swing.JButton();
            amt1 = new javax.swing.JLabel();
            panescroll = new javax.swing.JScrollPane();
            textarea1 = new javax.swing.JTextArea();
            quitbutt1 = new javax.swing.JButton();
            clearbutton = new javax.swing.JButton();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setTitle("McBride Financial Services Mortgage Calculator"); //displays title bar text
            amtofloan.setText("Enter the dollar amount of your Mortgage:"); // text area title for where user puts dollar amount of mortgage
            term.setText("Select Your Term and Interest Rate:"); // text area title for where user puts in term and interest rate selection
            radiobutt1.setText("7 years at 5.35% interest"); // sets button text for first radio button
            radiobutt1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); // sets border for radiobutt1
            radiobutt1.setMargin(new java.awt.Insets(0, 0, 0, 0)); // sets margin for radiobutt1
            radiobutt1.addActionListener(new java.awt.event.ActionListener()
                public void actionPerformed(java.awt.event.ActionEvent e) // class for action event
                    radiobutt1ActionPerformed(e);
            radiobutt2.setText("15 years at 5.5% interest");// sets button text for second radio button
            radiobutt2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); // sets border for radiobutt2
            radiobutt2.setMargin(new java.awt.Insets(0, 0, 0, 0)); // sets margin for radiobutt2
            radiobutt2.addActionListener(new java.awt.event.ActionListener()
                public void actionPerformed(java.awt.event.ActionEvent e) // class for action event
                    radiobutt2ActionPerformed(e);
            radiobutt3.setText("30 years at 5.75% interest");// sets button text for third and final radio button
            radiobutt3.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));// sets border for radiobutt3
            radiobutt3.setMargin(new java.awt.Insets(0, 0, 0, 0));// sets margin for radiobutt3
            radiobutt3.addActionListener(new java.awt.event.ActionListener()
                public void actionPerformed(java.awt.event.ActionEvent e)// class for action event
                    radiobutt3ActionPerformed(e);
            calculatebutt1.setText("Submit"); // submit button text
            calculatebutt1.addActionListener(new java.awt.event.ActionListener()
                public void actionPerformed(java.awt.event.ActionEvent e)
                    calculatebutt1ActionPerformed(e);
              // sets text area size
            textarea1.setColumns(20);
            textarea1.setEditable(false);
            textarea1.setRows(5);
            panescroll.setViewportView(textarea1);
            quitbutt1.setText("Quit"); // quit button text
            quitbutt1.addActionListener(new java.awt.event.ActionListener()
                public void actionPerformed(java.awt.event.ActionEvent e)
                    quitbutt1ActionPerformed(e);
         //layout
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(26, 26, 26)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(panescroll, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addContainerGap())
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(amt1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 222, Short.MAX_VALUE)
                                .addComponent(calculatebutt1)
                                .addGap(75, 75, 75))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(radiobutt3)
                                    .addComponent(radiobutt2)
                                    .addComponent(radiobutt1)
                                    .addComponent(term)
                                    .addComponent(amtofloan)
                                    .addComponent(text1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addContainerGap(224, Short.MAX_VALUE)))))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(277, Short.MAX_VALUE)
                    .addComponent(quitbutt1)
                    .addGap(70, 70, 70))
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(31, 31, 31)
                    .addComponent(amtofloan)
                    .addGap(14, 14, 14)
                    .addComponent(text1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(20, 20, 20)
                    .addComponent(term)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(radiobutt1)
                    .addGap(15, 15, 15)
                    .addComponent(radiobutt2)
                    .addGap(19, 19, 19)
                    .addComponent(radiobutt3)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(calculatebutt1)
                        .addComponent(amt1))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(panescroll, javax.swing.GroupLayout.DEFAULT_SIZE, 112, Short.MAX_VALUE)
                    .addGap(18, 18, 18)
                    .addComponent(quitbutt1)
                    .addGap(20, 20, 20))
            pack();
        } // Ends java components initialization
        private void quitbutt1ActionPerformed(java.awt.event.ActionEvent e)
        {// starts event_quitbutt1ActionPerformed
            System.exit(1);
        }// starts event_quitbutt1ActionPerformed
        static NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.US);
        static NumberFormat np = NumberFormat.getPercentInstance();
        static NumberFormat ni = NumberFormat.getIntegerInstance();
        static BufferedReader br;
        private void calculatebutt1ActionPerformed(java.awt.event.ActionEvent e)
        { // starts event_calculatebutt1ActionPerformed
        public void actionToBePerformed(ActionEvent e)
         if ("Clear". equals(e.getActionCommand())
         calculatePayment();
         else if
         amtofloan.settext("");
         intrst.settext("");
         loanspan.settext("");
         monthlypayments.settext("");
         rate.settext("");
         term.settext("")
         intRate=Integer.parseInt(Rate.showtext());
         DecimalFormat money = new DecimalFormat("$0.00");
            amt1.setText(null);
            textarea1.setText(null);
            double pmntamt;
            double intrst;
            double amounnt1;
            int loanspan;
            double interestmonthly, principlemonthly, balanceofloan;
            int balanceremainder, amtoflines;
            np.setMinimumFractionDigits(2);
        br = new BufferedReader(new InputStreamReader(System.in));
      amtoflines = 0;
            try
                    amounnt1=Double.parseDouble(text1.getText());
            catch (Exception evt)
                amt1.setText("Enter total amount due on mortgage");
                return;
            if(radiobutt1.isSelected())
                intrst=0.0535;
                loanspan=7;
            else if(radiobutt2.isSelected())
                intrst=0.055;
                loanspan=15;
            else if(radiobutt3.isSelected())
                intrst=0.0575;
                loanspan=30;
            else
                amt1.setText("Select term of loan and interest rate");
                return;
        textarea1.append(" For mortgage amount " + nf.format(amounnt1)+"\n"+" with mortgage term " + ni.format(loanspan) + " years"+"\n"+" and interest rate of " + np.format(intrst)+"\n"+" the monthly payment is " + nf.format(getMortgagePmt(amounnt1, loanspan, intrst))+"\n"+"\n");
        balanceofloan = amounnt1 - ((getMortgagePmt(amounnt1, loanspan, intrst)) - (amounnt1*(intrst/12)));
        balanceremainder = 0;
        do
            interestmonthly = balanceofloan * (intrst/12);// monthly interest
             principlemonthly = (getMortgagePmt(amounnt1, loanspan, intrst)) - interestmonthly;//*Principal payment each month minus interest
            balanceremainder = balanceremainder + 1;
            balanceofloan = balanceofloan - principlemonthly;//remaining balance
            textarea1.append(" Principal on payment  " + ni.format(balanceremainder) + " is " + nf.format(principlemonthly)+"\n");
                    textarea1.append(" Interest on payment  " + ni.format(balanceremainder) + " is " + nf.format(interestmonthly)+"\n");
                    textarea1.append(" Remaining balance on payment  " + ni.format(balanceremainder) + " is " + nf.format(balanceofloan)+"\n"+"\n"+"\n");
         while (balanceofloan > 1);
        }// starts event_jRadioBtton1Action Performed
        public static double getMortgagePmt(double balance, double term, double rate)
                double monthlyRate = rate / 12;
                double pmntamt = (balance * monthlyRate)/(1-Math.pow(1+monthlyRate, - term * 12));
                return pmntamt;
        private void radiobutt3ActionPerformed(java.awt.event.ActionEvent e)
        {// starts event_radiobutt3ActionPerformed
             if(radiobutt2.isSelected())
                radiobutt2.setSelected(false);
             if(radiobutt1.isSelected())
                radiobutt1.setSelected(false);
        }// ends event_radiobutt3ActionPerformed
        private void radiobutt2ActionPerformed(java.awt.event.ActionEvent e)
        {// starts event_radiobutt2ActionPerformed
             if(radiobutt1.isSelected())
                radiobutt1.setSelected(false);
             if(radiobutt3.isSelected())
                radiobutt3.setSelected(false);
        }// ends event_radiobutt2ActionPerformed
        private void radiobutt1ActionPerformed(java.awt.event.ActionEvent e)
        {// starts event_radiobutt1ActionPerformed
            if(radiobutt2.isSelected())
                radiobutt2.setSelected(false);
            if(radiobutt3.isSelected())
                radiobutt3.setSelected(false);
        }// ends event_radiobutt1ActionPerformed
        public static void main(String args[]) //main method start
            java.awt.EventQueue.invokeLater(new Runnable()
                public void run()
                    new MortgageCalcv7().setVisible(true);
        // declares variables
        private javax.swing.JButton calculatebutt1;
        private javax.swing.JButton quitbutt1;
        private javax.swing.JButton clearbutton;
        private javax.swing.JLabel amtofloan;
        private javax.swing.JLabel term;
        private javax.swing.JLabel amt1;
        private javax.swing.JRadioButton radiobutt1;
        private javax.swing.JRadioButton radiobutt2;
        private javax.swing.JRadioButton radiobutt3;
        private javax.swing.JScrollPane panescroll;
        private javax.swing.JTextArea textarea1;
        private javax.swing.JTextField text1;
    } //end MortgageCalcv7.javaEverything was fine until I tried to add the clear button. Now it won't compile and gives me the following errors. Please if you could find it in your kind heart to help a girl out, I would be forever in your debt. Thanks in advance!
    MortgageCalcv7.java:211: illegal start of expression
    public void actionToBePerformed(ActionEvent e)
    ^
    MortgageCalcv7.java:213: ')' expected
         if ("Clear". equals(e.getActionCommand())
         ^
    MortgageCalcv7.java:218: '(' expected
         else if
         ^
    MortgageCalcv7.java:219: illegal start of expression
         ^
    MortgageCalcv7.java:225: ';' expected
         term.settext("")
         ^
    MortgageCalcv7.java:291: illegal start of expression
    public static double getMortgagePmt(double balance, double term, double rate)
    ^
    6 errors
    Edited by: cheesegoddess on Oct 12, 2008 7:49 AM

    You guys were very helpful, thank you! Thank you so very much!! The others needed braces somewhere and I took else out and that line compiles now. Thank you, thank you, thank you.
    I am down to 1 error now. I cannot find where there is a missing bracket, if that is the problem.
    The line erring is:
    211    public void actionToBePerformed(ActionEvent e)and the error I am still getting is:
    MortgageCalcv7.java:211: illegal start of expression
    public void actionToBePerformed(ActionEvent e)
    ^
    Any ideas? TIA.

  • Please help with common program!!

    First I want to say that I did search to forum and I have not found a roman numeral conversion program written with a user defined class. Im not good with the terminology but the two programs are "working together" however I cannot get the output to print properly.......so maybe they arent working together. Anyway here is my code for the two and the output I am getting. The program is to convert a roman numeral to an integer value.
       public class Roman
           public static int numeralToInt(char ch)
             switch(ch)
                case 'M':
                   return 1000;
                case 'D':
                   return 500;
                case 'C':
                   return 100;
                case 'L':
                   return 50;
                case 'X':
                   return 10;
                case 'V':
                   return 5;
                case 'I':
                   return 1;
                case '0':
                   return 0;
             return 0;
    import java.util.*;
       import javax.swing.JOptionPane;
       import java.io.*;
       import javax.swing.*;
        public class RomanMain extends Roman
          static Scanner console =new Scanner(System.in);
           public static void main(String[]args)
                              throws FileNotFoundException, InputMismatchException
             Roman r=new Roman();
             System.out.println("Please enter a Roman Numeral for Conversion");
             console.next();   
             System.out.println("The converted value is:"+r);
       }This is very basic, all I am trying to do right now is get the correct output. I have tested it just by using M which should equal 1000. However I get the following.
    The converted value is:[email protected] in advance
    Robert

    Im not even gonna respond to your question db. I go to class 15 hours a week work 40 and spend another 20 studying for my OOP class and writing code, as well ascountless hours on my other homework. I work my ass off and when I get hung up I come here and read API's and browse forums archives looking for answers and when all else fails I come to the forums and ask. I've learned through surfing all these forums that most of you are assholes and have no interest in helping people. In fact most of you come off as thought the only reason you are here is cuase your self proclaimed java experts and you want all us newbies to bow down to you. I do appreciate everyone here that is not an asshole for helping, but anyone else that is just a total fuckwad can piss off. DB next time try asking a question without accusing someone of copying code.
    Once again thanks to everyone that is polite about helping people. Im sure i violated teh code of conduct but if i dont get kicked out of here for good, when i get better at java I'm gonna devote time to helping students and not being a dickhead. Until then Adios I'm off to a forum that is helpful and not demeaning.
    Robert

  • Need help with java program

    Modify the Inventory Program by adding a button to the GUI that allows the user to move to the first item, the previous item, the next item, and the last item in the inventory. If the first item is displayed and the user clicks on the Previous button, the last item should display. If the last item is displayed and the user clicks on the Next button, the first item
    should display. the GUI using Java graphics classes.
    ? Add a company logo to? Post as an attachment Course Syllabus
    here is my code // created by Nicholas Baatz on July 24,2007
      import java.awt.BorderLayout;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    public class Inventory2
    //main method begins execution of java application
    public static void main(final String args[])
    int i; // varialbe for looping
    double total = 0; // variable for total inventory
    final int dispProd = 0; // variable for actionEvents
    // Instantiate a product object
    final ProductAdd[] nwProduct = new ProductAdd[5];
    // Instantiate objects for the array
    for (i=0; i<5; i++)
    nwProduct[0] = new ProductAdd("Paper", 101, 10, 1.00, "Box");
    nwProduct[1] = new ProductAdd("Pen", 102, 10, 0.75, "Pack");
    nwProduct[2] = new ProductAdd("Pencil", 103, 10, 0.50, "Pack");
    nwProduct[3] = new ProductAdd("Staples", 104, 10, 1.00, "Box");
    nwProduct[4] = new ProductAdd("Clip Board", 105, 10, 3.00, "Two Pack");
    for (i=0; i<5; i++)
    total += nwProduct.length; // calculate total inventory cost
    final JButton firstBtn = new JButton("First"); // first button
    final JButton prevBtn = new JButton("Previous"); // previous button
    final JButton nextBtn = new JButton("Next"); // next button
    final JButton lastBtn = new JButton("Last"); // last button
    final JLabel label; // logo
    final JTextArea textArea; // text area for product list
    final JPanel buttonJPanel; // panel to hold buttons
    //JLabel constructor for logo
    Icon logo = new ImageIcon("C:/logo.jpg"); // load logo
    label = new JLabel(logo); // create logo label
    label.setToolTipText("Company Logo"); // create tooltip
    buttonJPanel = new JPanel(); // set up panel
    buttonJPanel.setLayout( new GridLayout(1, 4)); //set layout
    // add buttons to buttonPanel
    buttonJPanel.add(firstBtn);
    buttonJPanel.add(prevBtn);
    buttonJPanel.add(nextBtn);
    buttonJPanel.add(lastBtn);
    textArea = new JTextArea(nwProduct[3]+"\n"); // create textArea for product display
    // add total inventory value to GUI
    textArea.append("\nTotal value of Inventory "+new java.text.DecimalFormat("$0.00").format(total)+"\n\n");
    textArea.setEditable(false); // make text uneditable in main display
    JFrame invFrame = new JFrame(); // create JFrame container
    invFrame.setLayout(new BorderLayout()); // set layout
    invFrame.getContentPane().add(new JScrollPane(textArea), BorderLayout.CENTER); // add textArea to JFrame
    invFrame.getContentPane().add(buttonJPanel, BorderLayout.SOUTH); // add buttons to JFrame
    invFrame.getContentPane().add(label, BorderLayout.NORTH); // add logo to JFrame
    invFrame.setTitle("Office Min Inventory"); // set JFrame title
    invFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // termination command
    //invFrame.pack();
    invFrame.setSize(400, 400); // set size of JPanel
    invFrame.setLocationRelativeTo(null); // set screem location
    invFrame.setVisible(true); // display window
    // assign actionListener and actionEvent for each button
    firstBtn.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent ae)
    textArea.setText(nwProduct[0]+"\n");
    } // end firstBtn actionEvent
    }); // end firstBtn actionListener
    textArea.setText(nwProduct[4]+"n");
    // prevBtn.addActionListener(new ActionListener()
    // public void actionPerformed(ActionEvent ae)
    // dispProd = (nwProduct.length+dispProd-1) % nwProduct.length;
    // textArea.setText(nwProduct.display(dispProd)+"\n");
    // } // end prevBtn actionEvent
    // }); // end prevBtn actionListener
    } // end main
    } // end class Inventory2
    class Product
    protected String prodName; // name of product
    protected int itmNumber; // item number
    protected int units; // number of units
    protected double price; // price of each unit
    protected double value; // value of total units
    public Product(String name, int number, int unit, double each) // Constructor for class Product
    prodName = name;
    itmNumber = number;
    units = unit;
    price = each;
    } // end constructor
    public void setProdName(String name) // method to set product name
    prodName = name;
    public String getProdName() // method to get product name
    return prodName;
    public void setItmNumber(int number) // method to set item number
    itmNumber = number;
    public int getItmNumber() // method to get item number
    return itmNumber;
    public void setUnits(int unit) // method to set number of units
    units = unit;
    public int getUnits() // method to get number of units
    return units;
    public void setPrice(double each) // method to set price
    price = each;
    public double getPrice() // method to get price
    return price;
    public double calcValue() // method to set value
    return units * price;
    } // end class Product
    class ProductAdd extends Product
    private String feature; // variable for added feature
    public ProductAdd(String name, int number, int unit, double each, String addFeat)
    // call to superclass Product constructor
    super(name, number, unit, each);
    feature = addFeat;
    }// end constructor
    public void setFeature(String addFeat) // method to set added feature
    feature = addFeat;
    public String getFeature() // method to get added feature
    return feature;
    public double calcValueRstk() // method to set value and add restock fee
    return units * price * 0.05;
    public String toString()
    return String.format("Product: %s\nItem Number: %d\nIn Stock: %d\nPrice: $%.2f\nType: %s\nTotal Value of Stock: $%.2f\nRestock Cost: $%.2f\n\n\n",
    getProdName(), getItmNumber(), getUnits(), getPrice(), getFeature(), calcValue(), calcValueRstk());
    } // end class ProductAddI can not get all the buttons to work and do not know why can someone help me

    You have to have your code formatted correctly to begin with before you add the code tags. All your current code is left-justified and is not indented correctly.
    I only see that you've added an actionlistener to the "first" button.
    I recommend that you:
    1) again, do this first in a nonGUI class, then use this nonGUI class in your GUI class.
    2) Have a integer variable that holds the location of the current Product that your application is pointing to.
    3) Have a method called getProduct(int index) that returns the product that is at the location specified by the index in your array / arraylist / or whatever collection that you are using.
    4) Have your first button set index to 0 and then call getProduct(index).
    5) Have your last button set your index to the last product in your collection (i.e.: index = productCollection.length - 1 if this is an array), and then call getProduct(index).
    5) Have your next button increment your index up to the maximum allowed and then call getProduct(index). If it's an array it goes up to the array length - 1.
    6) If you want the next button to cause the index to roll over to the first, when you are at the last then then increment the index and mod it ("%" operator) by the length of the array...

  • Help with java program: Finding the remaining Gas in a Car

    I am a java newbie and I know this is a simple program but I am not getting the required result. Any help will be appreciated.
    Here is the code for Car.java :
    class Car{
         public  double gasTank;
         public  double drive;
         public  double fueleff;
         public Car()
              gasTank = 0;
         public Car(double rate)
              fueleff = rate;
              gasTank = 0;
         public void eff(double rate)
              fueleff = rate;
         public void drive(double amountDrove)
              drive = amountDrove;
              double amtRem = (gasTank-(drive/fueleff));
              gasTank = amtRem;
         public void addGas(double amountPumped)
              double amtRem = gasTank + amountPumped;
              gasTank = amtRem;
         public double getGas()
              return gasTank;
    }Here is the code for CarTester.java :
    public class CarTester {
      public static void main(String[] arg) {
        Car myHybrid = new Car();
        double amtRem = myHybrid.getGas();
        myHybrid.eff(50);
        myHybrid.addGas(20);
        myHybrid.drive(100);
        System.out.println("Amount Remaining: " + amtRem + " Gallons");
    }I should be getting 18 Gallons in the gasTank but I am getting 0.0. What am I doing wrong?

    And replace
    public void drive(double amountDrove)
    drive = amountDrove;
    double amtRem = (gasTank-(drive/fueleff));
    gasTank = amtRem;
    }with
    public void drive(double amountDrove)
      drive = amountDrove;
      gasTank -= drive/fueleff; // same logic as for +=
    }Cheers =)

  • Please help with my program

    I'm a newbie, i wrote a simple dictanary program, but i can't make it run properly. there are no errors but there is a problem...
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.regex.*;
    public class Dictionary{
    public static void main(String args[]){
    DicWin dic = new DicWin("Dictionary");
    class DicWin extends Frame implements ActionListener{
    Panel[] panels = new Panel[2];
    private static String REGEX = "^";
    Button ok;
    TextField text;
    String[] words;
    TextArea textF;
    public DicWin(String title){
         super(title);
         ReadDic("Mueller24.txt");
         setLayout(new GridLayout(2,1));
         panels[0] = new Panel();
         panels[1] = new Panel();
         First(panels[0]);
         Second(panels[1]);
         add(panels[0]);
         add(panels[1]);
         pack();
         setVisible(true);
    public void First(Container con){
         ok = new Button("OK");
         text = new TextField(20);
         con.add(ok);
         ok.addActionListener(this);
         con.add(text);
    public void Second(Container con){
         textF = new TextArea(5,20);
         con.add(textF);
    public void actionPerformed(ActionEvent e)
    String text2 = text.getText();
    Pattern p = Pattern.compile(REGEX + text2);
    for(int j=0;j<words.length;j++){
    Matcher m = p.matcher(words[j]);
    if(m.find())
         textF.setText(textF.getText() + "\n" + words[j]);
    private void ReadDic (String FileName){
    String line;
    int i=0;
    BufferedReader in = null;
    try{
    in = new BufferedReader(new FileReader("Mueller24.txt"));
         while((line = in.readLine())!=null)
         i++;
         words = new String;
         i=0;
         while((line = in.readLine())!=null)
         words[i]=line;
         i++;
    catch(IOException e){
    System.out.println("Error Loading the file.");

    Please make the ReadDic() method as following.
    private void ReadDic(String FileName) {
    String line;
    int i = 0;
    BufferedReader in = null;
    try {
    in = new BufferedReader(new FileReader("Mueller24.txt"));
    while ((line = in.readLine()) != null) {
    i++;
    words = new String[10];
    i = 0;
    while ((line = in.readLine()) != null) {
    words[i] = line;
    i++;
    } catch (IOException e) {
    System.out.println("Error Loading the file.");
    Please notice the line
    words = new String;
    in your original program should be something like following,
    words = new String[10]
    and the line,
    words = line;
    should be
    words[i] = line;
    I hope this would help.
    Pramoda

  • Need help with Java Programming

    Hello All,
    I dont know how to save all the lines separatly and then work with the numbers?
    Example TxtIn:
    2 5
    0 9 2 3 4 // I dont know how many lines will appear, and dont know how many numbers in a line
    1 2 3 9
    1 5 4
    2 0 0 5 6
    2 5 1 9
    4 6 1 5
    4 9 1 8
    9 1 4 8
    9 5 0
    Example TxtOut:
    1 9 4 0
    I would really appreciate your help in this.
    In my code, i only past one time in the text file, and clear the numbers of the list, but i need to make more check =S
    Here is the code:
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.ArrayList;
    import java.util.Scanner;
    import java.util.StringTokenizer;
    * @author Antonio
    public class web {
        /** Creates a new instance of Main */
         * @param args the command line arguments
        public static void main(String[] args) throws FileNotFoundException {
            int contador;
            ArrayList<Integer> lista = new ArrayList<Integer>();
            Scanner scn = new Scanner(new File("in.txt"));
            try {
            PrintWriter fileOut = new PrintWriter(new FileWriter("out.txt"));
            int ciudades = scn.nextInt();
            int aerolineas = scn.nextInt();
            int ciudadabuscar = scn.nextInt();
            int aerolinea = scn.nextInt();
            int bandera=0;
            while (scn.hasNextLine()){
                    String cad = scn.nextLine();
                    StringTokenizer st = new StringTokenizer(cad," ");
             while (st.hasMoreTokens())
                    String t = st.nextToken();
                    lista.add ( Integer.parseInt(t) );
               int a[]= new int[lista.size()];
               for (int x=0; x<lista.size(); x++)
                            a[x] = lista.get(x);
                          for (int x=0; x<lista.size(); x++)
                   for (x=1;x<lista.size();x++){
                            if (ciudadabuscar == a[0] && aerolinea == a[1])//tenia x=1
                                for (x=2;x<lista.size();x++)
                                { fileOut.printf("%d ",a[x]);
                                  ciudadabuscar= a[2];
                                  bandera = 1;}
                         lista.clear();
            if(bandera==0){
            fileOut.println("No hay destinos posibles por esta línea");
            fileOut.close();
            }catch(FileNotFoundException ex){}catch(IOException ex){}
    }

    #1 Solution is the same as i am working but...if i found AND another pair needs tobe searched...i dont know how to start again with step 1...
    i onli continues reading..that is why i am never show
    2 5//i am reading the file looking for 2 and 5
    0 9 2 3 4
    1 2 3 9
    1 5 4 // I NEVER show the number 4....
    2 0 0 5 6
    2 5 1 9 // here i found them...and now i have to look in the file 1 5 and 9 5 (but 1 5 are before this..so i can never found them)
    4 6 1 5
    4 9 1 8
    9 1 4 8
    9 5 0 // here i found 9 5
    Correct OutTxt: 1 9 4 0
    My OutTxt: 1 9 0...Never show the number 4, because i dont know how to start again...
    thank u
    Edited by: Ing_Balderas on Dec 11, 2009 2:25 PM

  • Please help with java.text.MessageFormat...

    Hi all
    I'm reasonably new to java and have been struggling with this one for a while. I wonder if anyone can help?
    The following code...
    Object[] testArgs = {new Long(1273), "MyDisk"};
    MessageFormat form = new MessageFormat(
    "The disk \"{1}\" contains {0} file(s).");
    System.out.println(form.format(testArgs));
    ...gives the following output...
    The disk "MyDisk" contains 1,273 file(s).
    I simply want to get rid of the comma, so that the output becomes...
    The disk "MyDisk" contains 1273 file(s).
    Any ideas? Many thanks for reading my thread and for any help you may be able to offer!
    Kind Regards
    Jon

    contains {0,number,#} file(s).

  • Help with Java program and PKGBUILD

    Hey guys, I'm fairly new to Arch and very new to making packages. I write a lot of my stuff in Java, and I know that Java is normally a pain to package on Linux systems. I have had a good look at the Java Packaging Guidelines, http://wiki.archlinux.org/index.php/Jav … Guidelines and I see that it says about not bothering compiling from Java source and just provide the JARs (am I correct?). So my question is, if I were to make a PKGBUILD for my Java based program, would the build() block just basically create the folders in the filesystem and move the content (JARs etc) to the folders? And then create the shell script in the appropriate location?
    Forgive me I have the completely wrong idea...
    Many thanks

    Hey guys, I'm fairly new to Arch and very new to making packages. I write a lot of my stuff in Java, and I know that Java is normally a pain to package on Linux systems. I have had a good look at the Java Packaging Guidelines, http://wiki.archlinux.org/index.php/Jav … Guidelines and I see that it says about not bothering compiling from Java source and just provide the JARs (am I correct?). So my question is, if I were to make a PKGBUILD for my Java based program, would the build() block just basically create the folders in the filesystem and move the content (JARs etc) to the folders? And then create the shell script in the appropriate location?
    Forgive me I have the completely wrong idea...
    Many thanks

Maybe you are looking for

  • Infoset query BI 7.0

    Hi All BW gurus , i want a clear picture how to create an infoset query and when to go for infoset and infoset query in GENERIC Extaction . anyone pls send the screen shots how to create and extract data to bw side from  infoset query  , my email is

  • Unable to close the cursors in the database

    While executing a stored program unit(containing three cursors and sub programs or functions containing another two cursors) through forms the client running the form stops responding. While checking the database the open_cursor view reports that the

  • Problem in BAPI_OBJCL_CHANGE / BAPI_OBJCL_CREATE FM

    Hi, My requirement is to Create a  Batch Recod by using BAPI_BATCH_CREATE and BAPI_OBJCL_CREATE to create data for classification if an entry doesnot exist in MCHA table. If the entry exits in MCHA i need to change the classification for which i am u

  • Referring to SQL comment table in Script Logic

    Dear all,   If i have the following combination of dimensions, i.e. "DimA, DimB and DimC", and they will point to a comment in the comment table in SQL, how do i grab the [Comment] from the comment table to be used in my script logic.   I was adviced

  • Real Time XI

    HI, I am new to XI. Can anybody tell me where actually XI used in Real Time! after doing the course, i got some knowledge that communicating with B2B applications. Is it supports between EAI(enterpeise application integration) also? And in what other