Need help with Java, have a few questions about my Applet

Purpose of the program: To create a mortgage calculator that will allow the user to input the loan principal then select 1 of 3 choices from a combo-box (7 years @ 5.35%, 15 years @ 5.50%, 30 years @ 5.75%).
Problem: My program was working properly (so I thought). I can get the program to properly compile and run through TextPad. However, I noticed that when the user clicks the calculate more than once (with the same input), it slightly alters the output calculations. So that is my first question, Why is it doing that?  How can I get it only calculate that information once unless the user changes it etc?
My next question is regarding my exit button. I was told by my instructor (who has already stated he won't help any of us) that my exit button does not work for an applet and only for an application. So, how can I create an exit button that will work with an applet? I thought I did it right but I can't find any resources online for this.
Next question, why isn't my program properly validating invalid input? My program should only allow numeric input and nothing more.
And last question, when invalid input is entered and the user clicks calculate, why isn't my JOptionPane window for error messages not displaying?
I know my code is a little long so I have to post this in two messages. Please don't criticize me for what I am doing, that is why I am learning and have come to this forum for help. Thanks
import java.applet.Applet;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.text.NumberFormat;
import java.text.DecimalFormat;
// Creating the main class
public class test extends JApplet implements ActionListener
     // Defining of format information
     JLabel heading = new JLabel("McBride Financial Services Mortgage Calculator");
     Font newFontOne = new Font("TimesRoman", Font.BOLD, 20);
     Font newFontTwo = new Font("TimesRoman", Font.ITALIC, 16);
     Font newFontThree = new Font("TimesRoman", Font.BOLD, 16);
     Font newFontFour = new Font("TimesRoman", Font.BOLD, 14);
     JButton calculate = new JButton("Calculate");
     JButton exitButton = new JButton("Quit");
     JButton clearButton = new JButton("Clear");
     JLabel instructions = new JLabel("Please Enter the Principal Amount Below");
     JLabel instructions2 = new JLabel("and Select a Loan Type from the Menu");
     // Declaration of variables
     private double principalAmount;
     private JLabel principalLabel = new JLabel("Principal Amount");
     private NumberFormat principalFormat;
     private JTextField enterPrincipal = new JTextField(10);
     private double finalPayment;
     private JLabel monthlyPaymentLabel = new JLabel("  Monthly Payment    \t         Interest Paid    \t \t            Loan Balance");
     private NumberFormat finalPaymentFormat;
     private JTextField displayMonthlyPayment = new JTextField(10);
     private JTextField displayInterestPaid = new JTextField(10);
     private JTextField displayBalance = new JTextField(10);
     // Creation of the String of arrays for the ComboBox
     String [] list = {"7 Years @ 5.35%", "15 Years @ 5.50%", "30 Years @ 5.75%"};
     JComboBox selections = new JComboBox(list);
     // Creation of the textArea that will display the output
     private TextArea txtArea = new TextArea(5, 10);
     StringBuffer buff = null;
          Edited by: LoveMyAJ on Jan 19, 2009 1:49 AM

// Initializing the interface
     public void init()
          // Creation of the panel design and fonts
          JPanel upper = new JPanel(new BorderLayout());
          JPanel middle = new JPanel(new BorderLayout());
          JPanel lower = new JPanel(new BorderLayout());
          JPanel areaOne = new JPanel(new BorderLayout());
          JPanel areaTwo = new JPanel(new BorderLayout());
          JPanel areaThree = new JPanel(new BorderLayout());
          JPanel areaFour = new JPanel(new BorderLayout());
          JPanel areaFive = new JPanel(new BorderLayout());
          JPanel areaSix = new JPanel(new BorderLayout());
          Container con = getContentPane();
          getContentPane().add(upper, BorderLayout.NORTH);
          getContentPane().add(middle, BorderLayout.CENTER);
          getContentPane().add(lower, BorderLayout.SOUTH);
          upper.add(areaOne, BorderLayout.NORTH);
          middle.add(areaTwo, BorderLayout.NORTH);
          middle.add(areaThree, BorderLayout.CENTER);
          middle.add(areaFour, BorderLayout.SOUTH);
          lower.add(areaFive, BorderLayout.NORTH);
          lower.add(areaSix, BorderLayout.SOUTH);
          heading.setFont(newFontOne);
          instructions.setFont(newFontTwo);
          instructions2.setFont(newFontTwo);
          principalLabel.setFont(newFontThree);
          monthlyPaymentLabel.setFont(newFontFour);
          displayInterestPaid.setFont(newFontFour);
          displayBalance.setFont(newFontFour);
          areaOne.add(heading, BorderLayout.NORTH);
          areaOne.add(instructions, BorderLayout.CENTER);
          areaOne.add(instructions2, BorderLayout.SOUTH);
          areaTwo.add(principalLabel, BorderLayout.WEST);
          areaTwo.add(enterPrincipal, BorderLayout.EAST);
          areaThree.add(selections, BorderLayout.NORTH);
          areaFour.add(calculate, BorderLayout.CENTER);
          areaFour.add(exitButton, BorderLayout.EAST);
          areaFour.add(clearButton, BorderLayout.WEST);
          areaFive.add(monthlyPaymentLabel, BorderLayout.CENTER);
          areaSix.add(txtArea, BorderLayout.CENTER);
          // Using the ActionListener to determine when each button is clicked
          calculate.addActionListener(this);
          exitButton.addActionListener(this);
          clearButton.addActionListener(this);
          enterPrincipal.requestFocus();
          selections.addActionListener(this);
     // The method that will perform specific actions defined below
     public void actionPerformed(ActionEvent e)
          Object source = e.getSource();
          buff = new StringBuffer();
          // Outcome of pressing the calculate button
          if (source == calculate)
               // Used to call upon the user chosen selection
               int selection = selections.getSelectedIndex();
               // If statement to call upon Loan One's Method
               if (selection == 0)
                    Double data = (Double)calculateLoanOne();
                    String sourceInput = data.toString();
                    displayMonthlyPayment.setText(sourceInput);
                    txtArea.setText(buff.toString());
               // If statement to call upon Loan Two's Method
               else if (selection == 1)
                    Double data = (Double)calculateLoanTwo();
                    String sourceInput = data.toString();
                    displayMonthlyPayment.setText(sourceInput);
                    txtArea.setText(buff.toString());
               // If statement to call upon Loan Three's Method
               else if (selection == 2)
                    Double data = (Double)calculateLoanThree();
                    String sourceInput = data.toString();
                    displayMonthlyPayment.setText(sourceInput);
                    txtArea.setText(buff.toString());
               // Outcome of pressing the clear button
               else if (source == clearButton)
                    enterPrincipal.setText("");
                    displayMonthlyPayment.setText("");
                    selections.setSelectedIndex(0);
                    txtArea.setText("");
               // Outcome of pressing the quit button
               else if (source == exitButton)
                    System.exit(1);
     // Method used to validate user input
     private static boolean validate(JTextField in)
          String inText = in.getText();
          char[] charInput = inText.toCharArray();
          for(int i = 0; i < charInput.length; i++)
               int asciiVal = (int)charInput;
          if((asciiVal >= 48 && asciiVal <= 57) || asciiVal == 46)
          else
               JOptionPane.showMessageDialog(null, "Invalid Character, Please Use Numeric Values Only");
               return false;
               return true;

Similar Messages

  • Have a few questions about iPad before I get one

    I have a few questions about getting an ipad before I committ to get one.
    I have about 24 gb of itunes purchases in my itunes library, I am thinking of getting the 64 gb ipad. However, after you purchase the 64 gb, it will not truly be 64 gb,
    1) how much actual storage space would I have on a 64 gb ipad accounting for the os? On my macbook now I have a 164 gb hard drive but only access to about 148 gb for example.
    2) Would I be able to store the 24 gb of itunes purchases in icloud? How would I do that? Would I keep needing to go into the Purchase History tab in the ITunes store and download the song when I want to listen to it? My concern with this is that the item will no longer be "available in the Itunes store" and I will lose access to my music I purchased? 
    I would like to ditch the laptop and just have the ipad as my computer but want to know about these questions I have first.
    3) Can ipad and iphone now be charged without needing a laptop? Per last year's June 2011 conference when Lion and ICloud were announced, it was stated in Fall 2011 with iOS5 that people could get ipads and iphones and charge them without needing a laptop for syncing?

    1. About 57 on mine
    2. Subscribe to iTunes Match at a cost of about $25 per year - 25000 song limit I think
    http://www.apple.com/icloud/features/
    3. The iPad comes with a power adapter that plugs into a wall socket and that is the recommended way to charge it anyway. - not by using a computer
    http://www.apple.com/batteries/ipad.html
    You do not absolutely need a computer in order to use an iPad but you have to do more research to figure out if it will fit your needs that way.

  • 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

    ok so i have a midterm and need help this question that is gonna be on the midterm. i dont know how to do it and its worth 16 marks!!!! here it is
    the UW Orchestra wants to produce a CD containing all the pieces of music
    from its upcoming concert. In order to do that, it needs to calculate the total length of time for the
    CD. In addition, the conductor wishes to know which piece of music has the longest duration.
    Sample output for the program.
    The Swan (3.88)
    The Bee (0.98)
    Claire de Lune (6.02)
    Liebesfreund (3.38)
    Ragtime (3.48)
    The total time for the CD is 18.74 minutes.
    The longest piece is Claire de Lune.
    Do not include the HTML that is required to embed the program into a Web page (that is, show
    only what you would write between <script> and </script> tags).
    [4 marks] In the following space, define a function, Print, that takes two parameters, Title and
    Length, and outputs a line of text such that Title appears in italics, followed by Length in
    parentheses. The function also returns the value of Length.
    For example, Print("My World",30) will output the line
    My World (30)
    and return the value 30.
    Put your JavaScript program for the remainder of this question in the space provided on the next
    two pages.
    [9 marks]. For each piece of music, your program should input the title of the piece and the
    duration (in minutes) for that piece, and it should output a line showing those values using the
    Print function just defined. After all pieces have been listed, the program should output the
    total length of time for the CD, adding in 0.25 minutes between each piece of music (which is
    needed on the CD to separate the pieces).
    [3 marks] The program should also output the name of the piece that has the longest playing
    time.
    Use reasonable variable names, indentation and good programming style. Documentation and
    comments are not required, but you may add them to explain any assumptions you might want to
    make. You need not check that the input is valid, and you may assume that no two pieces have the
    same duration.
    can anyone help me out! i would be indebt of ur kindness if u can help me out!

    This forum is for Java, not JavaScript. The two have nothing to do with each other.
    And anyway, this is your studying, so you should try to do it, put forth your best effort, and ask specific questions (on the proper fourm).

  • Need help with Java app for user input 5 numbers, remove dups, etc.

    I'm new to Java (only a few weeks under my belt) and struggling with an application. The project is to write an app that inputs 5 numbers between 10 and 100, not allowing duplicates, and displaying each correct number entered, using the smallest possible array to solve the problem. Output example:
    Please enter a number: 45
    Number stored.
    45
    Please enter a number: 54
    Number stored.
    45 54
    Please enter a number: 33
    Number stored.
    45 54 33
    etc.
    I've been working on this project for days, re-read the book chapter multiple times (unfortunately, the book doesn't have this type of problem as an example to steer you in the relatively general direction) and am proud that I've gotten this far. My problems are 1) I can only get one item number to input rather than a running list of the 5 values, 2) I can't figure out how to check for duplicate numbers. Any help is appreciated.
    My code is as follows:
    import java.util.Scanner; // program uses class Scanner
    public class Array
         public static void main( String args[] )
          // create Scanner to obtain input from command window
              Scanner input = new Scanner( System.in);
          // declare variables
             int array[] = new int[ 5 ]; // declare array named array
             int inputNumbers = 0; // numbers entered
          while( inputNumbers < array.length )
              // prompt for user to input a number
                System.out.print( "Please enter a number: " );
                      int numberInput = input.nextInt();
              // validate the input
                 if (numberInput >=10 && numberInput <=100)
                       System.out.println("Number stored.");
                     else
                       System.out.println("Invalid number.  Please enter a number within range.");
              // checks to see if this number already exists
                    boolean number = false;
              // display array values
              for ( int counter = 0; counter < array.length; counter++ )
                 array[ counter ] = numberInput;
              // display array values
                 System.out.printf( "%d\n", array[ inputNumbers ] );
                   // increment number of entered numbers
                inputNumbers++;
    } // end close Array

    Yikes, there is a much better way to go about this that is probably within what you have already learned, but since you are a student and this is how you started, let's just concentrate on fixing what you got.
    First, as already noted by another poster, your formatting is really bad. Formatting is really important because it makes the code much more readable for you and anyone who comes along to help you or use your code. And I second that posters comment that brackets should always be used, especially for beginner programmers. Unfortunately beginner programmers often get stuck thinking that less lines of code equals better program, this is not true; even though better programmers often use far less lines of code.
                             // validate the input
       if (numberInput >=10 && numberInput <=100)
              System.out.println("Number stored.");
      else
                   System.out.println("Invalid number.  Please enter a number within range."); Note the above as you have it.
                         // validate the input
                         if (numberInput >=10 && numberInput <=100)
                              System.out.println("Number stored.");
                         else
                              System.out.println("Invalid number.  Please enter a number within range."); Note how much more readable just correct indentation makes.
                         // validate the input
                         if (numberInput >=10 && numberInput <=100) {
                              System.out.println("Number stored.");
                         else {
                              System.out.println("Invalid number.  Please enter a number within range.");
                         } Note how it should be coded for a beginner coder.
    Now that it is readable, exam your code and think about what you are doing here. Do you really want to print "Number Stored" before you checked to ensure it is not a dupe? That could lead to some really confused and frustrated users, and since the main user of your program will be your teacher, that could be unhealthy for your GPA.
    Since I am not here to do your homework for you, I will just give you some advice, you only need one if statement to do this correctly, you must drop the else and fix the if. I tell you this, because as a former educator i know the first thing running through beginners minds in this situation is to just make the if statement empty, but this is a big no no and even if you do trick it into working your teacher will not be fooled nor impressed and again your GPA will suffer.
    As for the rest, you do need a for loop inside your while loop, but not where or how you have it. Inside the while loop the for loop should be used for checking for dupes, not for overwriting every entry in the array as you currently have it set up to do. And certainly not for printing every element of the array each time a new element is added as your comments lead me to suspect you were trying to do, that would get real annoying really fast again resulting in abuse of your GPA. Printing the array should be in its own for loop after the while loop, or even better in its own method.
    As for how to check for dupes, well, you obviously at least somewhat understand loops and if statements, thus you have all the tools needed, so where is the problem?
    JSG

  • Need help with Java always get error

    hey guys need help
    this the problem i get :
    I go to certain websites and I get this error with firefox.
    This Site requires that JavaScript be enabled.
    It is enabled.
    This is the one of the errors in java script console with firefox.
    Error: [Exception... "'Component does not have requested interface' when calling method: [nsIInterfaceRequestor::getInterface]" nsresult: "0x80004002 (NS_NOINTERFACE)" location: "<unknown>" data: no]
    I have installed the java script from there home site and did a test and says everything is fine. Any ideas?
    please help

    Hi 49ers,
    Sorry not to have any real idea of how to help you out here, but this is a Java forum, not JavaScript.
    Some Firefox expert may stumble across your post and be able to offer some advice (I hope they do) but this isn't really the best place to post such questions.
    Try here: http://www.webdeveloper.com/forum/forumdisplay.php?s=&forumid=3
    Good luck!
    Chris.

  • Need help with Java Script to perform a calculation in Adobe Acrobat Pro 9 form

    I have a form (test) that I am creating in Adobe Acrobat Pro 9.
    I need help creating custom Java Script so I can get the desired answer.
    1) There are several questions in each group that require a numerical answer between 0-4
    2) There is a total field set up to sum the answers from all above questions
    3) The final "score" takes the answer from Step 2 above and divides by the total possible answer
    Any help on what Java Script I need to complete this would be greatly appreciated!
    I've attached a "spreadsheet" that shows it in more detail as well as what formulas I used in Excel to get the desired end result.
    Thanks in advance.

    Have you tried the "The field is the average of:"?

  • Need help with Java applet, might need NetBeans URL

    I posted the below question. It was never answered, only I was told to post to the NetBeans help forum. Yet I don't see any such forum on this site. Can someone tell me where the NetBeans help forum is located (URL).
    Here is my original question:
    I have some Java source code from a book that I want to compile. The name of the file is HashTest.java. In order to compile and run this Java program I created a project in the NetBeans IDE named javaapplication16, and I created a class named HashTest. Once the project was created, I cut and pasted the below source code into my java file that was default created for HashTest.java.
    Now I can compile and build the project with no errors, but when I try and run it, I get a dialog box that says the following below (Ignore the [...])
    [..................Dialog Box......................................]
    Hash Test class wasn't found in JavaApplication16 project
    Select the main class:
    <No main classes found>
    [..................Dialog Box......................................]
    Does anyone know what the problem is here? Why won't the project run?
    // Here is the source code: *****************************************************************************************************
    import java.applet.*;
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.event.*;
    import java.util.*;
    public class HashTest extends Applet implements ItemListener
    // public static void main(String[] args) {
    // Hashtable to add tile images
    private Hashtable imageTable;
    // a Choice of the various tile images
    private Choice selections;
    // assume tiles will have the same width and height; this represents
    // both a tile's width and height
    private int imageSize;
    // filename description of our images
    private final String[] filenames = { "cement.gif", "dirt.gif", "grass.gif",
    "pebbles.gif", "stone.gif", "water.gif" };
    // initializes the Applet
    public void init()
    int n = filenames.length;
    // create a new Hashtable with n members
    imageTable = new Hashtable(n);
    // create the Choice
    selections = new Choice();
    // create a Panel to add our choice at the bottom of the window
    Panel p = new Panel();
    p.add(selections, BorderLayout.SOUTH);
    p.setBackground(Color.RED);
    // add the Choice to the applet and register the ItemListener
    setLayout(new BorderLayout());
    add(p, BorderLayout.SOUTH);
    selections.addItemListener(this);
    // allocate memory for the images and load 'em in
    for(int i = 0; i < n; i++)
    Image img = getImage(getCodeBase(), filenames);
    while(img.getWidth(this) < 0);
    // add the image to the Hashtable and the Choice
    imageTable.put(filenames[i], img);
    selections.add(filenames[i]);
    // set the imageSize field
    if(i == 0)
    imageSize = img.getWidth(this);
    } // init
    // tiles the currently selected tile image within the Applet
    public void paint(Graphics g)
    // cast the sent Graphics context to get a usable Graphics2D object
    Graphics2D g2d = (Graphics2D)g;
    // save the Applet's width and height
    int width = getSize().width;
    int height = getSize().height;
    // create an AffineTransform to place tile images
    AffineTransform at = new AffineTransform();
    // get the currently selected tile image
    Image currImage = (Image)imageTable.get(selections.getSelectedItem());
    // tile the image throughout the Applet
    int y = 0;
    while(y < height)
    int x = 0;
    while(x < width)
    at.setToTranslation(x, y);
    // draw the image
    g2d.drawImage(currImage, at, this);
    x += imageSize;
    y += imageSize;
    } // paint
    // called when the tile image Choice is changed
    public void itemStateChanged(ItemEvent e)
    // our drop box has changed-- redraw the scene
    repaint();
    } // HashTest

    BigDaddyLoveHandles wrote:
    h1. {color:red}MULTIPOST: [http://forums.sun.com/thread.jspa?threadID=5358840&messageID=10564025]{color}
    That wasn't attention-grabbing enough apparantly. Let's try it again.
    h1. {color:red}MULTIPOST: [http://forums.sun.com/thread.jspa?threadID=5358840&messageID=10564025]{color}
    h1. {color:red}MULTIPOST: [http://forums.sun.com/thread.jspa?threadID=5358840&messageID=10564025]{color}
    h1. {color:red}MULTIPOST: [http://forums.sun.com/thread.jspa?threadID=5358840&messageID=10564025]{color}
    h1. {color:red}MULTIPOST: [http://forums.sun.com/thread.jspa?threadID=5358840&messageID=10564025]{color}
    h1. {color:red}MULTIPOST: [http://forums.sun.com/thread.jspa?threadID=5358840&messageID=10564025]{color}

  • Need help with java J2Se 5.0 upgrade 2

    Having problems with Java when playing on Pogo, the Vaults of Atlantis. When loading, I am getting a message that says that I need to remove and download again, java. That it is not working correctly. I did that yesterday, 05/27/05 and am still experiencing the problem but only after signing off from Pogo and AOL and then trying to sign back on again later in the day. I have to shutdown my computer and bring it back up again and then I can load the Vaults of Atlantis. I have noticed that when I do sign-off from Pogo and AOL, that my java cup stays on in my deskbar. Is that supposed to be normal or is it supposed to disappear? If it is supposed to disappear, what can I do to fix that problem?
    Please, can anyone help?

    Go here http://www.java.com/en/ and click "Download Now".
    If that has problems, click the "Manual Download" link and download the "Windows (Offline Installation)".
    If there are problems, review the Help information to resolve.

  • Need help with java will even pay

    I need extreme help. I just don't have time lately to write these programs and I have fallen extremely behind. Basically all I need is to pass this class and right now until I can get some more help I just can't make the deadlines. If someone could help me I will pay you just like a tutor.
    Requirements for Lab.
    You will need to develop a variety of classes for this lab. Specifically, you need to create:
    +1. a "PersonGUI" class that displays fields for a person's: firstName, lastName, identificationNum, and sex.+
    +2. a "StudentGUI" class that provides Java components for the entry of: classification (freshman, sophomore, junior, senior, or graduate student), and Checkboxes for (a student being in the Honor's program and/or in the ROTC).+
    +3. a "FacultyGUI" class that provides Java components for the entry of: rank (instructor, assistant, associate, or full professor), years of service, and salary.+
    +4. a "Statistics" class that, when instantiated, creates an object containing an instance variable for each of the the statistical values outlined below. (Each of these instance variables should be declared to be "private".)+
    Your main Lab6 class should provide a means for the user to:
    +1. Specify the kind of personal data to be entered (Student or Faculty), and+
    +2. Then, depending on the choice made, appropriate fields should be displayed to allow the user to input appropriate information for the type of personal data being entered, and+
    +3. Controls that support the following functionality:+
    * a "CANCEL" control that will terminate any operation currently being performed and return the user to the "Startup" window.
    * a "SAVE" control that will cause the just entered data to be harvested from the graphical user interface and the appropriate statistics to be updated. Note: this function may NOT be performed if any of the student or faculty member data fields have not been filled in.
    * a "RESET" control that will erase all information recorded to date (i.e., all summary variables are reset to zero).
    * a "CLEAR" control that will erase all fields for the personal data currently being entered.
    * and a "DISPLAY TOTALS" control that will display, when pressed, the following data:
    +1. For students:+
    +1. total number of students entered so far,+
    +2. number who are male and number who are female,+
    +3. number of freshmen, sophomores, juniors, seniors, and graduate students,+
    +4. number of students who are in the Honor's program and number who are in the ROTC.+
    +2. For faculty:+
    +1. total number of faculty entered so far,+
    +2. number who are male and number who are female,+
    +3. the name and salary of the highest paid faculty member on campus.+
    Your program should validate numeric data to the extent:
    +1. no numeric field (id number, years of service, or salary) may be left blank by the user. If done so, the user should be alerted to enter a numeric value.+
    +2. when the user enters a "years of service" value for a faculty member - the value entered should be verified to be a valid integer value in the range 1 to 50. If the data entered is outside the valid range or is not a valid integer - your program should reject the value and prompt the user that invalid data has been entered and that a new value is necessary.+
    +3. when a faculty salary is entered, verify that it is a floating-point value in the range $35,000 to $200,000. Handle invalid data as described above.+
    +4. Similarly, if an invalid integer value is entered for the identification number, the value should be rejected and the user prompted to reenter.+
    +5. Information should not be saved, nor should statistical values be updated, until all numeric data has been validated.+
    Note -- You will be graded on appropriate use of instance vs. local variables, use of methods, and passing parameters and returning appropriate values.
    +1. The 'Statistics" class MUST provide "mutator" and "accessor" methods that are required to access values or to modify the values of any variable. REMEMBER ALL VARIABLES ARE DECLARED TO BE "private"!!+
    +2. You should implement methods to verify the data, as detailed above. The methods should return boolean values indicating whether the data is acceptable or not.+

    Sorry to hear about your problems - lack of time, having fallen behind, imminent failure etc - but none of these are Java problems.
    This site deals with Java problems: compiler or runtime behaviour that people can't understand. If you have problems of that sort (and especially if solving those problems would help with the problems you did describe) then post them.
    Otherwise you would seem to be in the wrong place.

  • Need help with JAVA and Listeners

    Thanks to all the people who have been helping me so far. I really appreciate it. I have another question.
    I am bulding a GUI where it will consist of buttons and textfields. I want the textfields to display data but also permit the user to interact, i.e. enter data into the textfield and then when the enter key is depressed my program will evaluate the data and determine to use it or throw a pop up error window. If the data is acceptable than that textfield will change accordingly and depending on the data might possibly update the two other textfields.
    I know there is an ActionListener for JButtons and a MouseListener. Is there a Listener for the enter key? What would be a simple method to implement my logic? Thanks again! I really appreciate, hopefully I can become more fluent in JAVA!

    Swing related questions should be posted in the Swing forum.
    enter data into the textfield and then when the enter key is depressed my program will evaluate the data and determine to use it Well, JTextField supports an ActionListener, which means an ActionEvent is fired when focus is on the text and and the Enter key is used.
    However, what happens if the user uses the Tab key to move from field to field, then no event is fired and the Action Event is not generated. Maybe you can use an InputVerifier which will cause the text field to be validated when the text field loses focus.
    Or, maybe you are talking about activating the "Enter" button when the enter key is pressed no matter what component has focus. In this case you should be using getRootPane().setDefaultButton(...);
    Your need to clarify your requirement.

  • Need help with Java fonts (broken in 10.4.9)

    Hi, folks,
    There was a post late last year (maybe October?) that explained how to fix a problem with Java fonts. (OK...I know NOTHING, but I am able to follow directions!)
    I play games on Yahoo.com (Literati and Word Racer) that now have unreadable fonts since I upgraded 3 days ago. I seem to remember last year's fix had something to do with disabling fonts. I just can't remember what to do and have spent an hour looking for the post.
    If you can find it - or tell me what to do - I'd appreciate it. Remember, I need really specific directions.
    Thanks.
    iMac duo core   Mac OS X (10.4.9)  

    I am able to set up a new account and work but even after deleting all preferences the problem persists in my admin account.
    I'll try to look for any font corruption and clear font cache but having to reinstall the OS is a real drag. Not sure why PS should corrupt the OS, itself.
    Any chance I can uninstall and remove PS then install again?

  • Need Help with Java Homework

    This is my first post here, seeking some help with my java homework. I am required to create a program to write out a receipt for a pizza company: name of company, total number of pizzas, costs (including tax etc), and print out the receipt after taking an order from the customer.
    This is a beginner's java class and my book isn't very good at explaining (mainly because it says "will be discussed in ch 14" when we're in ch 1-3 and it's an essential part of the program).
    But anyways, if anyone is up right now, would be helpful for some help. I have a general idea of what I wanna do, but the program so far is very messy and incomplete and having trouble getting it to look nice and proper.

    well there were two ways of doing this, im only 2 weeks new in java so bear with me.....I was gonna set 3 classes, one appclass, one order form, and one receipt. I was told you can combine the order and receipt in 1 class, but I thought doing 3 woudl be better to help me learn more...anyways, I haven't worked on the appclass yet, but for the order I have a very messy set of codes. I know that it's wrong but it's a start, im looking for any input cause the book does not explain very much.
    For the order class, I will be doing showinputdialog boxes for how many pizzas, the sizes, and the toppings. Here is what I have so far ( i know it is VERY messy and disorganized but I am a bit lost in where I should go next):
    * @author AlexNguyen
    * To take the order with number of pizzas and toppings
    package project2;
    import javax.swing.JOptionPane;
    public class Order {
         public int NumberOfPizzas;
         public char Pepperoni;
         public char Sausage;
         public char Cheese;
         public Order(int n) {
         NumberOfPizzas = n;
         JOptionPane.showInputDialog("Enter Number of Pizzas"));
    String ptype; {
         public void start();
         public void takeOrder();
         public void writeReceipt();
              public void takeOrder();
              ptype = Topping
    public String selectPizza(char P, char S, char C) {
         Pepperoni = P;
         Sausage = S;
         Cheese = C;
    public void numPizza(int numberOfPizzas) {
         num = numberOfPizzas;
    JOptionPane.showInputDialog("Topping for Pizza?");
    JOptionPane.showInputDialog("Pizza Size?");
    JOptionPane.showInputDialog("Number of Pizzas?");
    }

  • Need Help with Java Desktop CP Icon

    I just formatted and reinstalled Windows XP Home SP2 and installed the JRE 1.5.0.02. I usually see an icon in my Control Panel but it only appears in the Administrator's CP which I can reach in Safe Mode of course, but it would be easier to deal with if it appeared somewhere on my desktop/taskbar or CP (I am also an Admin). In Safe Mode I made sure that the right settings were made for displaying, but it doesn't.
    I know precious little about Java so I need help here.

    This forum is dedicated to Sun's Java Desktop System, an alternative desktop operating environment. Try reposting here:
    http://forum.java.sun.com/forum.jspa?forumID=54

  • Collage Students need help with Java project(Email Server) whats analysis?

    Hi im studying in collage at the moment and i have just started learning java this semester, the thing is my teacher just told us to do an project in java , since we just started the course and i dont have any prior knowledge about java i was wondering if some one could help me with the project.
    i choose Email Sevice as my project and we have to submit an analysis and design document , but how the hell am i suppose to know what analysis is ? i just know we use ER diagrams & DFD's in the design phase but i dont know what analysis means ?
    could some one tell me what analysis on an email service might be? and what analysis on a subject means? is it the codeing involved or some thing coz the teacher told us not to do any codeing yet so im completly stumped,
    oh and btw we are a group of 3 students who are asking u the help here coz all of us in our class are stupmed ?

    IN case any one is interested this is the analysis i wrote
    ANALYSIS
    Analysis means figuring out what the problem is, maybe what kinds of solutions might be appropriate
    1.     Introduction:-
    The very definition of analysis is an investigation of the component parts of a whole and their relations in making up the whole. The Analysis done here is for an emailing service called Flashmail, the emailing service is used to send out mails to users registered with our service, these users and there log activities will be stored in some where, the most desirable option at this time is a Database, but this can change as the scope of the project changes.
    2.     Customer Analysis:-
    We are targeting only 30 registered users at the moment but this is subject to change as the scale changes of the project .Each user is going to be entitled to 1MB of storage space at this time since we lack the desired infrastructure to maintain anything higher than 1MB but the end vision of the project is to sustain 1000 MB of storage space while maintaining a optimal bandwidth allocation to each user so as to ensure a high speed of activity and enjoyment for the Customer.
    The Service will empower the user to be able to send, read, reply, and forward emails to there specified locations. Since we are working on a limited budget we can�t not at this time enable the sending of attachments to emails, but that path is also left open by modularity of java language, so we can add that feature when necessary.
    3.     Processor Load Analysis:-
    The number of messages per unit time processing power will be determined on hand with various algorithms, since it is best not to waste processor power with liberally distributing messages per unit time. Hence the number of messages will vary with in proportion to the number of registered users online at any given time.
    4.     Database Decision Analysis:-
    The High level Requirements of the service will have to be decided upon, the details of which can be done when we are implementing the project itself. An example of high level requirements are database management, we have chosen not to opt for flat files because of a number of reasons, first off a flat files are data files that contain records with no structured relationships additional knowledge is required to interpret these files such as the file format properties. The disadvantages associated with flat files are that they are not fast, they can only be read from top to bottom, and usually they have to be read all the way through. Though there is are advantages of Flat files they are that it takes up less space than a structured file. However, it requires the application to have knowledge of how the data is organized within the file.
    Good databases have key advantage over flat files concurrency. When you just read stuff from file it�s easy, but tries to synchronize multiple updates or writes into flat file from scripts that run in different process spaces.
    Whereas a flat file is a relatively simple database system in which each database is contained in a single table. In contrast, relational database systems can use multiple tables to store information, and each table can have a different record format.
    5.     Networking Analysis:-
    Virtually every email sent today is sent using two popular protocols known as SMTP (Simple Mail Transfer Protocol) and MIME (Multipurpose Internet Mail Extensions).
    1.     SMTP (Simple Mail Transfer Protocol)
    The SMTP protocol is the standard used by mail servers for sending and receiving email. In order to send email we will first establish a network connection to our SMTP server. Once you have finished sending your email message it is necessary that you disconnect from the SMTP server
    2.     MIME (Multipurpose Internet Mail Extensions)
    The MIME protocol is the standard used when composing email messages.

Maybe you are looking for