Where to start? Need help with classes

My question involves those classes he wants us to make. I don't really get the concept of classes, so could someone tell me what they think he wants us to do? And try to explain it to me in terms I might be able to understand. Does that mean for us to use subclasses or use separate files for each class? Or could I do either? I'm so confused :(
Assignment: Write a program that consists of the classes listed below.
Player Class: The Player Class consists of at least two elements -- the player name and a list of scores for
games. The score attribute is not used in Program #3 but will be needed in Program #4. Include in the
class appropriate accessor and mutator methods for each element in the class. You may have other
attributes if needed.
Team Class: The Team class consists of at least 6 elements -- the name of the team and five players from
the Player class. Include in the class appropriate accessor and mutator methods for each element in the
class. You may have other attributes if needed.
Course Syllabus Page 3
Input3 class: The Input3 class is provided for you. The Input3 class supplies data for your program. The
Input3 class has a public method called getNextString, which returns a string with the input for your
program, one after the other. You must use this class to get the data for your program. See Input3.java on
WebCT to understand the class construction.
Your program should display the roster of each team in alphabetical order by last name.
This is the Input3 that he gave us to work with if anyone needs to see it:
public class Input3
     private String[] input = new String[40];
     private static int StringNum = -1;
     public static final int NUMBER_OF_TEAMS = 3;
     public static final int NUMBER_OF_PLAYERS = 5;
     public Input3()
          //The first six inputs will be for the first team
          input[0] = "LAKERS";
          input[1] = "Kobe Bryant";
          input[2] = "Derek Fisher";
          input[3] = "Shaquille O'Neal";     
          input[4] = "Karl Malone";
          input[5] = "Brian Cook";
          //The next six inputs will be for the second team
          input[6] = "MAVERICKS";
          input[7] = "Antoine Walker";
          input[8] = "Dirk Nowitzki";
          input[9] = "Tony Delk";
          input[10] = "Shawn Bradley";
          input[11] = "Travis Best";
          //The next six inputs will be for the third team
          input[12] = "KNICKS";
          input[13] = "Mike Sweetney";
          input[14] = "Allan Houston";
          input[15] = "Howard Eisley";
          input[16] = "Kurt Thomas";
          input[17] = "Shanon Anderson";
     //This method returns the strings one after the other.
     public String getNextString()
          StringNum++;
          return input[StringNum];
}<br>
<br>
<br>
Thanks

You could put the classes in separate files, but it's not necessary. They wouldn't be called 'subclasses' here, as that word is specific to inheritance, which you don't need here. Here's an example of using multiple classes:
public class MainClass {
    public static void main(String [] args) {
     OtherClass1 oc1 = new OtherClass1(3);
     OtherClass2 oc2 = new OtherClass2("hello");
     System.out.println("" + oc1.getInt());
     System.out.println(oc2.getString());
class OtherClass1 {
    int someInt;
    public OtherClass1(int i) {
        someInt = i;
    public getInt() {
     return someInt;
class OtherClass2 {
    String someString;
    public OtherClass2(String s) {
        someString = s;
    public getString() {
        return someString;
}and like BDLH said above, it's preferred to put them in separate files. Just make sure the file name is EXACTLY the same as the class name, followed by .java

Similar Messages

  • Need help with classes

    I''ve just started out with Java and I need help with my latest program.
    The program looks someting like this:
    public class MultiServer {
       public static void main(Straing[] args) {
          ServerGUI GUI = new ServerGUI();
    public class ServerGUI extends JFrame implements ActionListener {
       private TextArea textArea;
       public ServerGUI() {
          //setting up the JFrame and stuff like that
       public void actionPerformed(ActionEvent event) {
          if(button == addButton) {
             addGUI add = new addGUI();
    public class addGUI extends JFrame implements ActionListener {
        private TextField t1 = new TextField(25);
        public addGUI() {
          //setting up the JFrame and stuff like that
       public void actionPerformed(ActionEvent event) {
          if(button == printButton) {
             textArea.append("THIS DOES NOT WORK!");
    }   The problem is as follows: I want to be able to write text in the textArea in class ServerGUI from the class addGUI, but I can't. I hope you understand what I mean.
    How is this fixed? Please help me!

    public void actionPerformed(ActionEvent event) {
          if(button == addButton) {
             addGUI add = new addGUI(textArea);
    public class addGUI extends JFrame implements ActionListener {
        private TextArea textArea;
        public addGUI(TextArea textArea) {
            this.textArea = textArea;
        }/Kaj

  • Need help with class design

    I want to design and use one or more classes for a particular project I am working on.
    I need some advice hopefully from someone who has experience in this area. Basically,
    for this particular problem I have two database tables. I want the first class to
    represent the first database table and the second class to represent the second
    database table. An object of the first class will be created first, and then if certain
    criteria are met then an object of the second class will be created.
    Question:
    Should I use classical inheritance and let the first class inherit from the second class?
    Or should I use the containment delegation model and embed an object of the second
    class in the first class?
    ----Tables------
    For example, my first table ET_UserData looks something like this:
    ET_UserData
    (PK)UserName
    Password
    FirstName
    LastName
    My second table ET_DetailedUserData looks like this
    ET_DetailedUserData
    (FK)UserName
    WorkAddress
    WorkPhoneNumber
    CityWhereEmployed
    SocialSecurityNumber
    City
    State
    StreetAdress
    PrimaryTelephoneNumber
    AlternatePhoneNumber
    HasRegistered
    RegistrationDate
    RegistrationTime
    CreditCardNumber
    NameOfPrimaryContact
    DateOfBirth
    Weight
    EyeColor
    Height
    Member
    Here is are some pseudo classes for the two classes.
    Class UserData
    string UserName
    string FirstName
    string LastName
    Class DetailedUserData /* For a classical approach, sub class off of class UserData */
    /* UserData ThisUser --> Containment delegation model */
    string (FK)UserName
    string WorkAddress
    string WorkPhoneNumber
    string CityWhereEmployed
    string SocialSecurityNumber
    string City
    string State
    string StreetAdress
    Int PrimaryTelephoneNumber
    Int AlternatePhoneNumber
    Bool HasRegistered
    Int RegistrationDate
    Int RegistrationTime
    Int CreditCardNumber
    String NameOfPrimaryContact
    Int DateOfBirth
    Int Weight
    Int EyeColor
    Int Height
    bool Member
    }

    Thank you for your help. If you can continue to help me I would appreciate it.
    I and another developer did the database design. Pretty solid design. Plus we have all of the requirements
    which are very good too.
    Originally I wanted just one table to contain all of the data associated with a user. Instead of ET_UserData and ET_Detailed user data I wanted just one table. But I decided to break this table up into the two tables for the following reason.
    1.) This is a web application where each user logs into a web form. At a minimum, in order to use the website the session associated with each user needs the UserName, Password, First and last name.
    This is the data in the first table.
    If they choose to do more specialized functions on this website, then they will need all of the information (Attributes) that are located in the second table. In general 40% of the time all users will need information located in the second table.
    My reasoning for breaking the table into two seperate tables is that I wanted to minimize the amount of data involved in a result set, created from the sql query. The math tells me that 60% of the time most of the data in the result set will not be used.
    2.) If I create one class to represent all of the data/attributes in both tables, then my reasoning is that their will be alot of overhead in the single class because 60% of the time, a majority of the attributes are not needed and used.
    I would deeply appreciate your help with this. You seem to have great insight and advice. Please help me as I increase the duke dollars Sir.

  • Need help with class object? Please somoen

    hey guys,
    It's been few days since i'm working on making a small bingogame program but i'm getting stuck frequantly.
    I've different classes, in the main class i'm asking the user to input number of players who would like to play then i'm asking the player's name and how many bingoCards each player wants.
    I'm stroing all that info in a BingoPlayer class's array object. But for some reason when i get out from the loop and try to retrive the info from that array it only gives me the last input entry (player's name & number of cards) at any index of the array.
    Can please someone tell me how i can store the given information for each player in that object array on different indices of the array?
    I'm providing the code where i've the problems:
    public class BingoGame
        public static BingoPlayer players[] = new BingoPlayer[5];
        public static void main() throws IOException {
            int numPlayers = 0;
            int numCards [] = new int [5];
            String name [] = new String[4];
            BufferedReader input = new BufferedReader (new InputStreamReader(System.in)); //allows input
    // ask for the number players who wants to play
            System.out.print("Please enter the number of players in this game (2-5): ");
            numPlayers = Integer.parseInt(input.readLine());
    // make sure the entered value is within range
            while (numPlayers < 2 || numPlayers > 5) {
                System.out.println("Invalid number of players ");
                System.out.print("Please enter the number of players in this game (2-5): ");
                numPlayers = Integer.parseInt(input.readLine());
            System.out.println();
    //ask for the names and numebr of cards for entered number of players
    // and make sure the number of cards are within the range,
    //and assign the players that many cards using the BingoPlayer object 
            for (int i = 1; i <= numPlayers; i++) {
                System.out.print("Please enter name of player " + i + " : ");
                name[i] = input.readLine();
                System.out.println();
                System.out.print("Please enter the number of cards (1-5) for player " + i + " : ");
                numCards[i] = Integer.parseInt(input.readLine());
                while (numCards[i] < 1 || numCards[i] > 5) {
                    System.out.println("Invalid number of cards for the player " + i);
                    System.out.print("Please enter the number of cards (1-5) for player " + i + " : ");
                    numCards[i] = Integer.parseInt(input.readLine());
                System.out.println();
                players[i] = new BingoPlayer(name, numCards[i]);
    * here it only prints out the information for the last player, instead it should return the information for both of the player
    for (int k = 1; k <= numPlayers; k ++) {
    System.out.println(players[k]);
    //players[k].genCards();
    for example if i enter 2 players:
    Player1: name: Jami, number of cards 1
    Player2: name: Joey, number of cards 2
    in the last loop it just prints out :"Joey, 2" 2 times instead of printing out: "Jami, 1" & "Joey, 2"
    Please someone help! i really need to complete this within 2 days. Thanks in advance

    Without seeing BingoPlayer's implementation, all it
    would be would be a guess.
    My guess: The name and numCards members of that class
    are declared as static, so all instances share the
    same values.Thanks it worked, declaring them static was the main probelm..thank you very much

  • Need help with class info and cannot find symbol error.

    I having problems with a cannot find symbol error. I cant seem to figure it out.
    I have about 12 of them in a program I am trying to do. I was wondering if anyone could help me out?
    Here is some code I am working on:
    // This will test the invoice class application.
    // This program involves a hardware store's invoice.
    //import java.util.*;
    public class InvoiceTest
         public static void main( String args[] )
         Invoice invoice1 = new Invoice( "1234", "Hammer", 2, 14.95 );
    // display invoice1
         System.out.println("Original invoice information" );
         System.out.println("Part number: ", invoice1.getPartNumber() );
         System.out.println("Description: ", invoice1.getPartDescription() );
         System.out.println("Quantity: ", invoice1.getQuantity() );
         System.out.println("Price: ", invoice1.getPricePerItem() );
         System.out.println("Invoice amount: ", invoice1.getInvoiceAmount() );
    // change invoice1's data
         invoice1.setPartNumber( "001234" );
         invoice1.setPartDescription( "Yellow Hammer" );
         invoice1.setQuantity( 3 );
         invoice1.setPricePerItem( 19.49 );
    // display invoice1 with new data
         System.out.println("Updated invoice information" );
         System.out.println("Part number: ", invoice1.getPartNumber() );
         System.out.println("Description: ", invoice1.getPartDescription() );
         System.out.println("Quantity: ", invoice1.getQuantity() );
         System.out.println("Price: ", invoice1.getPricePerItem() );
         System.out.println("Invoice amount: ", invoice1.getInvoiceAmount() );
    and that uses this class file:
    public class Invoice
    private String partNumber;
    private String partDescription;
    private int quantityPurchased;
    private double pricePerItem;
         public Invoice( String ID, String desc, int purchased, double price )
              partNumber = ID;
         partDescription = desc;
         if ( purchased >= 0 )
         quantityPurchased = purchased;
         if ( price > 0 )
         pricePerItem = price;
    public double getInvoiceAmount()
         return quantityPurchased * pricePerItem;
    public void setPartNumber( String newNumber )
         partNumber = newNumber;
         System.out.println(partDescription+" has changed to part "+newNumber);
    public String getPartNumber()
         return partNumber;
    public void setDescription( String newDescription )
         System.out.printf("%s now refers to %s, not %s.\n",
    partNumber, newDescription, partDescription);
         partDescription = newDescription;
    public String getDescription()
         return partDescription;
    public void setPricePerItem( double newPrice )
         if ( newPrice > 0 )
    pricePerItem = newPrice;
    public double getPricePerItem()
    return pricePerItem;
    Any tips for helping me out?

    System.out.println("Part number:
    "+invoice1.getPartNumber;
    The + sign will concatenate invoice1.getPartNumber()
    after "Part number: " forming only one String.I added the plus sign and it gives me more errors:
    C:\>javac InvoiceTest.java
    InvoiceTest.java:16: operator + cannot be applied to java.lang.String
            System.out.println("Part number: ",   + invoice1.getPartNumber() );
                                                  ^
    InvoiceTest.java:17: cannot find symbol
    symbol  : method getPartDescription()
    location: class Invoice
            System.out.println("Description: ", + invoice1.getPartDescription() );
                                                          ^
    InvoiceTest.java:17: cannot find symbol
    symbol  : method println(java.lang.String,int)
    location: class java.io.PrintStream
            System.out.println("Description: ", + invoice1.getPartDescription() );
                      ^
    InvoiceTest.java:18: cannot find symbol
    symbol  : method getQuantity()
    location: class Invoice
            System.out.println("Quantity: ", + invoice1.getQuantity() );
                                                       ^
    InvoiceTest.java:18: cannot find symbol
    symbol  : method println(java.lang.String,int)
    location: class java.io.PrintStream
            System.out.println("Quantity: ", + invoice1.getQuantity() );
                      ^
    InvoiceTest.java:19: cannot find symbol
    symbol  : method println(java.lang.String,double)
    location: class java.io.PrintStream
            System.out.println("Price: ", + invoice1.getPricePerItem() );
                      ^
    InvoiceTest.java:20: cannot find symbol
    symbol  : method println(java.lang.String,double)
    location: class java.io.PrintStream
            System.out.println("Invoice amount: ", + invoice1.getInvoiceAmount() );
                      ^
    InvoiceTest.java:24: cannot find symbol
    symbol  : method setPartDescription(java.lang.String)
    location: class Invoice
            invoice1.setPartDescription( "Yellow Hammer" );
                    ^
    InvoiceTest.java:25: cannot find symbol
    symbol  : method setQuantity(int)
    location: class Invoice
            invoice1.setQuantity( 3 );
                    ^
    InvoiceTest.java:30: operator + cannot be applied to java.lang.String
            System.out.println("Part number: ", + invoice1.getPartNumber() );
                                                ^
    InvoiceTest.java:31: cannot find symbol
    symbol  : method getPartDescription()
    location: class Invoice
            System.out.println("Description: ", + invoice1.getPartDescription() );
                                                          ^
    InvoiceTest.java:31: cannot find symbol
    symbol  : method println(java.lang.String,int)
    location: class java.io.PrintStream
            System.out.println("Description: ", + invoice1.getPartDescription() );
                      ^
    InvoiceTest.java:32: cannot find symbol
    symbol  : method getQuantity()
    location: class Invoice
            System.out.println("Quantity: ", + invoice1.getQuantity() );
                                                       ^
    InvoiceTest.java:32: cannot find symbol
    symbol  : method println(java.lang.String,int)
    location: class java.io.PrintStream
            System.out.println("Quantity: ", + invoice1.getQuantity() );
                      ^
    InvoiceTest.java:33: cannot find symbol
    symbol  : method println(java.lang.String,double)
    location: class java.io.PrintStream
            System.out.println("Price: ", + invoice1.getPricePerItem() );
                      ^
    InvoiceTest.java:34: cannot find symbol
    symbol  : method println(java.lang.String,double)
    location: class java.io.PrintStream
            System.out.println("Invoice amount: ", + invoice1.getInvoiceAmount() );
                      ^
    16 errors

  • Need help with class I'm trying to write for school

    Hi,I'm taking my first Java class, and we're learning how to write classes. I've got MOST of the program and class to work, but I'm still having trouble with it.
    In the class I wrote, if I delete the "getWindTempF(strAlt)" the program runs fine, other than not doing the conversion to Fahrenheit. So, I'm guessing that there's a problem with my getWindTempF method. However, it is almost exactly a duplicate of my getWindTempC method, so I can't figure out what I'm doing wrong. The errors I get when I keep the "getWindTempF(strAlt)" in the prtWindInfo method are:
    java.lang.NumberFormatException: For input string: " "
         at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
         at java.lang.Integer.parseInt(Integer.java:426)
         at java.lang.Integer.parseInt(Integer.java:476)
         at NWSFD.getWindTempF(NWSFD.java:94)
         at NWSFD.prtWindInfo(NWSFD.java:162)
         at a19004.main(a19004.java:30)
    Exception in thread "main"
    ----jGRASP wedge2: exit code for process is 1.
    Again, the program and class work perfectly except for the getWindTempF. Any ideas would be greatly appreciated, and sorry for such a long post
    Here is the main program:
    import cs1.Keyboard;
    import java.text.NumberFormat;
    import java.text.SimpleDateFormat;
    import java.text.DateFormat;
    import java.util.Date;
    public class a19004
         // Instantiates the windsAloft object by using the NWSFD class
         public static void main (String[] args)
              final String FAA_FD="SAN 1405 2908+26 2911+19 2809+11 1307-09 0308-20 " +
              "032433 012543 352853";
              NWSFD windsAloft = new NWSFD(FAA_FD);     //Instantiate the NWSFD object
              System.out.println ("Winds Aloft");
              System.out.println ("as of " + windsAloft.getDate());
              System.out.println ("");
              System.out.println ("STA Alt Dir Speed TempC TempF");
              System.out.println ("");
              System.out.println (windsAloft.prtWindInfo("03"));
              System.out.println (windsAloft.prtWindInfo("06"));
              System.out.println (windsAloft.prtWindInfo("09"));
              System.out.println (windsAloft.prtWindInfo("12"));
              System.out.println (windsAloft.prtWindInfo("18"));
              System.out.println (windsAloft.prtWindInfo("24"));
              System.out.println (windsAloft.prtWindInfo("30"));
              System.out.println (windsAloft.prtWindInfo("34"));
              System.out.println (windsAloft.prtWindInfo("39"));
    And for the sake of brevity, just a part of the NWSFD class:
    import java.text.*;
    import java.util.Date;
    public class NWSFD
         // Set up variables
         private String strWea;
         // 3.a. Constructor
         public NWSFD (String strVar)
              strWea=strVar + " ";
         // 3.d.
         public String getWindTempC (String strAlt)
              String strVar;
              strVar = strWea.substring(getPos(strAlt) + 4, getPos(strAlt) + 7);
              if (strAlt.equals("03"))
                   strVar = strWea.substring(getPos(strAlt) +4, getPos(strAlt) + 5);
              if (strAlt.equals("30"))
                   strVar = "-" + strWea.substring(getPos(strAlt) +4, getPos(strAlt) + 6);
              if (strAlt.equals("34"))
                   strVar = "-" + strWea.substring(getPos(strAlt) +4, getPos(strAlt) + 6);
              if (strAlt.equals("39"))
                   strVar = "-" + strWea.substring(getPos(strAlt) +4, getPos(strAlt) + 6);
              if (strVar.equals(" "))
                   strVar = "N/A";
              return strVar;
         // 3.ed.
         public String getWindTempF (String strAlt)
              String strVar;
              String strFar;
              int intRet;
              int intFar;
              strFar = strWea.substring(getPos(strAlt) + 5, getPos(strAlt) + 7);
              if (strAlt.equals("03"))
                   strFar = strWea.substring(getPos(strAlt) +4, getPos(strAlt) + 5);
              if (strAlt.equals("30"))
                   strFar = "-" + strWea.substring(getPos(strAlt) +4, getPos(strAlt) + 6);
              if (strAlt.equals("34"))
                   strFar = "-" + strWea.substring(getPos(strAlt) +4, getPos(strAlt) + 6);
              if (strAlt.equals("39"))
                   strFar = "-" + strWea.substring(getPos(strAlt) +4, getPos(strAlt) + 6);
              if (strFar.equals(" "))
                   strVar = "N/A";
              intRet = Integer.parseInt(strFar);
              intFar = intRet * (9/5) + 32;
              strVar = Integer.toString(intRet++);
              return strVar;
         // 3.h.
         public String prtWindInfo (String strAlt)
              String strRet;
              strRet = strWea.substring(0,3) + " " + strAlt + "000" + " " +
                   getWindDir(strAlt) + " " + getWindSpeed(strAlt) + " " +
                   getWindTempC(strAlt) + "C " + getWindTempF(strAlt) + "F";
              return strRet;
    }

    Thank you for the reply, soni29. here is the code:
    public int getPos(String strAlt)
              int intAlt;
              int intRet;
              intAlt = Integer.parseInt(strAlt);
              switch (intAlt)
                   case 3:
                        intRet = 4;
                        break;
                   case 6:
                        intRet = 9;
                        break;
                   case 9:
                        intRet = 17;
                        break;
                   case 12:
                        intRet = 25;
                        break;
                   case 18:
                        intRet = 33;
                        break;
                   case 24:
                        intRet = 41;
                        break;
                   case 30:
                        intRet = 49;
                        break;
                   case 34:
                        intRet = 56;
                        break;
                   default:
                        intRet = 63;
              } //     Close switch
              return intRet;
    However, I really don't think there's a problem with any of the coding there. The only times I have problems with the program is when I'm trying to display the data from getWindTempF. If I omit that method, the program works perfectly. Basically, what the program is supposed to do, is hand a string (FAA_FD) to the NWSFD class, which then extracts data from it. Thank you again for the help...any other advice?

  • Need help with class inheritance

    I've got a class called jemAccount and i need to create a savings account class and a checking account class that inherit from it.
    Here is the jemAccount:
    public class jemAccount
    protected String myName;
    protected double myBalance;
    protected double[] withdrawls = new double [50];
    protected double[] deposits = new double [50];
    protected int withIndex = 0;
    protected int depIndex = 0;
    public jemAccount ()
    myBalance = 0;
    public jemAccount (String newName)
    myName = newName;
    myBalance = 0;
    public jemAccount (String newName, double newBal)
    myName = newName;
    myBalance = newBal;
    public void setName(String newName)
    myName = newName;
    public double balance()
    return myBalance;
    public void withdrawl (double amount)
    if (amount < 0)
    myBalance += amount;
    else
    myBalance -= amount;
    if (withIndex < 50)
    withdrawls[withIndex] = amount;
    withIndex++;
    public void deposit (double amount)
    if (amount > 0)
    myBalance += amount;
    if (depIndex < 50)
    deposits[depIndex] = amount;
    depIndex++;
    public void printAccount()
    System.out.println("Owner of account: " + myName);
    System.out.println("Balance of account: " + myBalance);
    System.out.println("Deposits: ");
    for (int i = 0; i < depIndex; i++)
    System.out.println(" " + deposits);
    System.out.println("");
    System.out.println("Withdrawls: ");
    for (int i = 0; i < withIndex; i++)
    System.out.println(" " + withdrawls[i]);
    System.out.println("");
    System.out.println("");
    } // end of class jemAccount
    Here are my requirements for the savings account class:
    � Call the class "abcSaveAccount".
    � Have this class inherit from "jemAccount"
    � Add a float for keeping track of the yearly interest rate of the checking account. Call this class variable "interest" Make it protected.
    � Add a public constructor for the savings account class. It should have one parameter, a float that initializes the new savings account class variable. This constructor should also call the parent class constructor with no arguments.
    � Add a public method for calculating interest. Call it "calcInterest". Have it take one parameter, an integer which represents the number of months to calculate the interest for. This method should return a float, the result of the interest calculation. For example, if 30 months are entered as a parameter of 30, then 2 and one/half years of interest on the balance are calculated and returned.
    Here are the requirements for the checking account class:
    � Call the class "abcCheckAccount"
    � Have this class inherit from "jemAccount"
    � Add an array for keeping track of the checks you write. For now, just make this an array of 100 doubles, very similar to withdrawals
    � Add a public constructor for the checking account class. It should have zero parameters. This constructor should also call the parent class constructor with no arguments.
    � Add a new public method to your checking account class. Call it "writeCheck". This should take one double parameter. If the value of the parameter is positive, subtract the parameter from the balance, and copy the value into the "checks" array. (Keep the checks and withdrawals separate.) Else do nothing.
    � Override the "printAccount" method. Have the checking account "printAccount" run its parent "class printAccount", then print out a list of the checks, after the list of the withdrawals.
    Here's what i have so far for the savings account class:
    public class abcSaveAccount extends jemAccount
    protected float interest;
    public void abcSaveAccount (float newSavings)
    super ();
    public calcInterest (int numberMonths)
    return interest;
    And here's what i have so far for the checking account class:
    public class abcCheckAccount extends jemAccount
    double[] checks = new doulbe[100];
    public abcCheckAccount ()
    super ();
    public writeCheck (double value)
    if (value >= 0)
    balance = balance - value;

    Few changes,
    public class abcCheckAccount extends jemAccount {
         private double[] checks = new double[100];
         private int checkIndex;
         public abcCheckAccount() {
              super ();
              checkIndex=0;
         public void writeCheck (double value) {
              if ( value >= 0) {
                   withdrawl(value);
                   checks[checkIndex++]=value;
         public void printAccount() {
              super.printAccount();
              System.out.println("Checks:");
              for (int i = 0; i < checkIndex; i++) System.out.println("     "+checks[ i ]);
              System.out.println("");
              System.out.println("");
    } // end of abcCheckAccount classand
    public class abcprog {
       public static void main (String args[]) {
              abcCheckAccount check = new abcCheckAccount();
              check.setName("Sudha");
              check.deposit(1000.0);
              check.deposit(200.0);
              check.withdrawl(112.0);
              check.writeCheck(300.0);
              check.printAccount();
              abcSaveAccount save = new abcSaveAccount(6);
              save.setName("Mike");
              save.deposit(1000.0);
              save.withdrawl(112.0);
              save.printAccount();
              System.out.println("Calculated Interest : "+save.calcInterest(120));
    }U can use this program to test your classes.
    Sudha

  • Need help with "class file contains wrong class"

    I have a dbUtil package as
    package dbUtil;
    public class dbConfig {
    public String getHost(String db) {
    This file called dbConfig.java has been compiled with -d option and rthe class files resides in dir <install_dir>/webapps/test/WEB-INF/classes/eb/dbUtil/
    I have a jsp file in <install_dir>/webapps/test/test.jsp which imports the dbUtil package
    <%@ page import="eb.dbUtil.dbConfig" %>
    and I am getting this error:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: -1 in the jsp file: null
    Generated servlet error:
    [javac] Compiling 1 source file
    /opt/hpws/tomcat/work/Standalone/localhost/test/test_jsp.java:12: cannot access eb.dbUtil.dbConfig
    bad class file: /opt/hpws/tomcat/webapps/test/WEB-INF/classes/eb/dbUtil/dbConfig.class
    class file contains wrong class: dbUtil.dbConfig
    Please remove or make sure it appears in the correct subdirectory of the classpath.
    import eb.dbUtil.dbConfig;
    ^
    1 error
    Can anyone tell me what am I doing wrong? I am using tomcat 4.1
    Thanks!
    L.

    Given your java file, the fully qualified name of the class is dbUtil.dbConfig.
    What you are importing is eb.dbUtil.dbConfig
    These things are not the same.
    The root of the classpath for the webapp is the classes directory.
    So either
    1 - specify dbConfig.java to be in package eb.dbUtil
    2 - move the class file into web-inf/classes/dbUtil/dbConfig.class, and import dbUtil.dbConfig.
    Also, by convention, classnames should start with a capital letter ie dbUtil.DbConfig.
    Cheers,
    evnafets

  • Need help with Class-Path and NCDFE

    This isn't a new issue, but I'm getting a variation of a problem a lot of people seem to have had. I was hoping someone out there can help me out.
    I have a jar file (imex.jar) sitting in c:\temp\imextest. I also have another jar file, commons-cli-1.0.jar sitting in c:\temp\imextest\lib.
    I want to run the jar in a standalone manner. My manifest has the following entries.
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.5.3
    Created-By: 1.4.2_01-b06 (Sun Microsystems Inc.)
    Main-Class: com.foo.imex.DirectoryImportExport
    Class-Path: lib/commons-cli-1.0.jar
    I am invoking it using the following command (from c:\temp\imextest)
    java -jar imex.jar -i -f c:\matt\RRBus\jiyun.xml -v
    I get this result:
    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/cli/ParseException
    It seems to me that I have my directory structure and manifest set up correctly, but maybe I don't (as it's not working). Does anyone see what I'm doing wrong here? (the "missing" class is in commons-cli-1.0.jar).
    Thanks,
    Matt

    perhaps jar file needed for parsing is not there in classpath...set it...in the classpath..

  • Need help with classes in Applets and drawing buildings.

    I'm trying to create an Applet that draws a starfield (I got that right) and then searches for any parameters in the Applet tag. The Applet then draws as many buldings as there are parameters in the Applet tag, and uses the number in the parameter as the height. I have it working OK, but it won't draw the buildings. Here is me code:
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.geom.*;
    import java.util.*;
    import javax.swing.*;
    public class Skyline extends Applet {
    public void init() {
    setBackground(Color.black);
    public void paint(Graphics g) {
    Graphics2D pen = (Graphics2D) g;
    Random generator = new Random();
    Stars starField = new Stars();
    starField.drawStars(pen, getWidth(), getHeight());
    int n = 1;
    String param = null;
    while((param = getParameter("param" + n)) != null) {
    n++;
    int startX = 0;
    int startY = getHeight();
    int height = 0;
    int width = getWidth() / (n + 2);
    Building structure = new Building();
    structure.drawBuilding(pen, height, width, startX, startY, n);
    class Stars {
    public void drawStars(Graphics2D pen, int Width, int Height) {
    Random generator = new Random();
    int runs = 1;
    while (runs <= 1000) {
    int Xcord = generator.nextInt(Width - 3);
    int Ycord = generator.nextInt(Height - 3);
    Ellipse2D.Double star
    = new Ellipse2D.Double(Xcord, Ycord, 3, 3);
    pen.setColor(Color.white);
    pen.fill(star);
    runs++;
    class Building {
    public void drawBuilding(Graphics2D pen, int height, int width, int startX, int startY, int n) {
    Random generator = new Random();
    int n2 = 1;
    int runs = 1;
    String input = "";
    int red = generator.nextInt(100),
    green = generator.nextInt(100),
    blue = generator.nextInt(100);
    pen.setColor(new Color(red, green, blue));
    while (runs <= n) {
    input = getParameter("building" + n2);
    height = Integer.parseInt(input);
    height = startY - height;
    Rectangle building = new Rectangle(startX, startY, height, width);
    pen.fill(building);
    startY = startY + width;
    n2++;
    runs++;
    Can anyone help me?

    That didn't work, so I looked at the code again and found some errors. I decided to rewrite it, here is the updated code...
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.geom.*;
    import java.util.*;
    import javax.swing.*;
    public class Skyline extends Applet {
    public void init() {
    setBackground(Color.black);
    public void paint(Graphics g) {
    Graphics2D pen = (Graphics2D) g;
    Random generator = new Random();
    Stars starField = new Stars();
    starField.drawStars(pen, getWidth(), getHeight());
    Building structure = new Building();
    structure.drawBuilding(pen);
    class Stars {
    public void drawStars(Graphics2D pen, int Width, int Height) {
    Random generator = new Random();
    int runs = 1;
    while (runs <= 1000) {
    int Xcord = generator.nextInt(Width - 3);
    int Ycord = generator.nextInt(Height - 3);
    Ellipse2D.Double star
    = new Ellipse2D.Double(Xcord, Ycord, 3, 3);
    pen.setColor(Color.white);
    pen.fill(star);
    runs++;
    class Building {
    public void drawBuilding(Graphics2D pen) {
    Random generator = new Random();
    int n = 1;
    int n2 = 1;
    int runs = 1;
    String input = "";
    String param = "";
    while ((param = getParameter("building" + n)) != null) {
    n++;
    int height = getHeight();
    int width = getWidth();
    int startX = 0;
    int startY = height;
    int red = generator.nextInt(100),
    green = generator.nextInt(100),
    blue = generator.nextInt(100);
    pen.setColor(new Color(red, green, blue));
    while (runs <= n) {
    height = getHeight();
    input = getParameter("building" + n2);
    height = Integer.parseInt(input);
    height = startY - height;
    Rectangle building = new Rectangle(startY, startX, height, width);
    pen.fill(building);
    startX = startX + width;
    n2++;
    runs++;
    I can get it to draw one large black building, but that's it.

  • I need Help with a website I've created

    I need help with a website I've created (www.jonathanhazelwood.com/lighthouse) I created the folowing site with dreamweaver at my current resolution 1366 by 768. Looks great on my screen resolution but if it is viewed on other resolutions the menu moves and some of the text above and below. How can I keep all content centered and working like it does on 1366 by 768 on all resolutions. The htm to my site is below I started off with a blank template through dreamweaver CS5.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>The Lighthouse Church</title>
    <style type="text/css">
    <!--
    body {
        font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
        background: #42413C;
        margin: 0;
        padding: 0;
        color: #000;
        background-color: #000;
    /* ~~ Element/tag selectors ~~ */
    ul, ol, dl { /* Due to variations between browsers, it's best practices to zero padding and margin on lists. For consistency, you can either specify the amounts you want here, or on the list items (LI, DT, DD) they contain. Remember that what you do here will cascade to the .nav list unless you write a more specific selector. */
        padding: 0;
        margin: 0;
    h1, h2, h3, h4, h5, h6, p {
        margin-top: 0;     /* removing the top margin gets around an issue where margins can escape from their containing div. The remaining bottom margin will hold it away from any elements that follow. */
        padding-right: 15px;
        padding-left: 15px; /* adding the padding to the sides of the elements within the divs, instead of the divs themselves, gets rid of any box model math. A nested div with side padding can also be used as an alternate method. */
    a img { /* this selector removes the default blue border displayed in some browsers around an image when it is surrounded by a link */
        border: none;
    /* ~~ Styling for your site's links must remain in this order - including the group of selectors that create the hover effect. ~~ */
    a:link {
        color: #42413C;
        text-decoration: underline; /* unless you style your links to look extremely unique, it's best to provide underlines for quick visual identification */
    a:visited {
        color: #6E6C64;
        text-decoration: underline;
    a:hover, a:active, a:focus { /* this group of selectors will give a keyboard navigator the same hover experience as the person using a mouse. */
        text-decoration: none;
    /* ~~ this fixed width container surrounds all other elements ~~ */
    .container {
        width: 960px;
        background: #FFF;
        margin: 0 auto; /* the auto value on the sides, coupled with the width, centers the layout */
    /* ~~ This is the layout information. ~~
    1) Padding is only placed on the top and/or bottom of the div. The elements within this div have padding on their sides. This saves you from any "box model math". Keep in mind, if you add any side padding or border to the div itself, it will be added to the width you define to create the *total* width. You may also choose to remove the padding on the element in the div and place a second div within it with no width and the padding necessary for your design.
    .content {
        padding: 10px 0;
    /* ~~ miscellaneous float/clear classes ~~ */
    .fltrt {  /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
        float: right;
        margin-left: 8px;
    .fltlft { /* this class can be used to float an element left in your page. The floated element must precede the element it should be next to on the page. */
        float: left;
        margin-right: 8px;
    .clearfloat { /* this class can be placed on a <br /> or empty div as the final element following the last floated div (within the #container) if the overflow:hidden on the .container is removed */
        clear:both;
        height:0;
        font-size: 1px;
        line-height: 0px;
    #apDiv1 {
        position:absolute;
        width:352px;
        height:2992px;
        z-index:1;
        top: 171px;
        left: 507px;
    #apDiv2 {
        position:absolute;
        width:961px;
        height:1399px;
        z-index:1;
        left: 187px;
        top: 1px;
    #apDiv3 {
        position:absolute;
        width:961px;
        height:1001px;
        z-index:1;
        top: -2px;
    #apDiv4 {
        position:absolute;
        width:963px;
        height:58px;
        z-index:1;
        left: 0px;
        top: 101px;
    #apDiv5 {
        position:absolute;
        width:961px;
        height:1505px;
        z-index:1;
        top: -5px;
    #apDiv6 {
        position:absolute;
        width:962px;
        height:150px;
        z-index:1;
        left: 0px;
        top: -1px;
    #apDiv7 {
        position:absolute;
        width:361px;
        height:25px;
        z-index:2;
        left: 35px;
        top: 1308px;
    #apDiv8 {
        position:absolute;
        width:320px;
        height:24px;
        z-index:2;
        left: 200px;
        top: 1479px;
    #apDiv9 {
        position:absolute;
        width:962px;
        height:63px;
        z-index:3;
        left: -10px;
        top: -1292px;
    #apDiv10 {
        position:absolute;
        width:270px;
        height:27px;
        z-index:2;
        left: 200px;
        top: 1478px;
    #apDiv11 {
        position:absolute;
        width:961px;
        height:44px;
        z-index:3;
        left: 195px;
        top: 183px;
    -->
    </style>
    <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
    <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    #apDiv12 {
        position:absolute;
        width:295px;
        height:23px;
        z-index:4;
        left: 198px;
        top: 1px;
    #apDiv13 {
        position:absolute;
        width:135px;
        height:22px;
        z-index:5;
        left: 1001px;
        top: 3px;
    #apDiv14 {
        position:absolute;
        width:309px;
        height:992px;
        z-index:1;
        left: 33px;
        top: 479px;
    #apDiv15 {
        position:absolute;
        width:327px;
        height:999px;
        z-index:1;
        left: 324px;
    #apDiv16 {
        position:absolute;
        width:262px;
        height:1000px;
        z-index:2;
        left: 674px;
        top: 477px;
    #apDiv17 {
        position:absolute;
        width:85px;
        height:34px;
        z-index:1;
        left: -379px;
        top: 1001px;
    #apDiv18 {
        position:absolute;
        width:200px;
        height:115px;
        z-index:6;
    #apDiv19 {
        position:absolute;
        width:168px;
        height:31px;
        z-index:3;
        left: 448px;
        top: 1451px;
    #apDiv20 {
        position:absolute;
        width:94px;
        height:33px;
        z-index:3;
        left: 384px;
        top: 1477px;
    body {
        background-color: #000;
        margin-left: 0px;
        margin-right: 0px;
    #apDiv21 {
        position:absolute;
        width:920px;
        height:200px;
        z-index:4;
        left: 19px;
        top: 233px;
    </style>
    </head>
    <body>
    <div class="container">
      <div class="content">
        <div id="apDiv5">
          <div id="apDiv16">
            <div id="apDiv17">
              <map name="Map2" id="Map2">
                <area shape="rect" coords="4,2,77,28" href="http://www.myspace.com/lighthousechurch1" />
              </map>
              <img src="paypal-donate-button.png" width="83" height="33" border="0" usemap="#Map" />
              <map name="Map" id="Map">
                <area shape="rect" coords="2,2,80,30" href="https://www.paypal.com/us/cgi-bin/webscr?cmd=_flow&SESSION=HgApKd0bxyPQv1ixwBW3HgWXaLxPIiT Po9gSsRELLQp72IZ2-_8uvSmCLRO&dispatch=5885d80a13c0db1f8e263663d3faee8d9384d85353843a619606 282818e091d0" />
              </map>
            </div>
          </div>
          <div id="apDiv21">
            <blockquote>
              <blockquote>
                <blockquote>
                  <blockquote>
                    <blockquote>
                      <blockquote>
                        <p><img src="faithexplosion.png" width="314" height="225" /></p>
                      </blockquote>
                    </blockquote>
                  </blockquote>
                </blockquote>
              </blockquote>
            </blockquote>
          </div>
          <div id="apDiv14">
            <div id="apDiv15">
              <div>
                <div>
                  <p> Special Message from Perry Stone </p>
                  <h2> Was Jesus Born on December 25?</h2>
                  <p> 12/20/2010 </p>
                  <p><img alt="iStock_000003631829XSmall" src="http://www.voe.org/images/iStock_000003631829XSmall.jpg" width="300" height="234" /></p>
                  <p>Last   year, in response to the growing number of Christians who celebrate   Hanukkah but hate Christmas, I wrote an article for this website titled   &ldquo;Hanukkah or Christmas?&rdquo; I explained why I think Jesus was either   conceived or birthed on December 25.</p>
                </div>
              </div>
              <div>
                <div><a href="http://www.voe.org/Prophecy-Update/what-happened-to-global-warming.html"> READ MORE</a>
                  <p> Prophecy Update </p>
                  <h2> What Happened to Global Warming?</h2>
                  <p> 12/17/2010 </p>
                  <p> </p>
                </div>
              </div>
              <div>
                <div></div>
              </div>
              <div>
                <div></div>
              </div>
            </div>
            <div>
              <p><font size="2">Special Word</font></p>
              <p><font size="2">January 7th, 2011</font></p>
              <p> <font size="2">Dear Viewers:</font></p>
              <p><font size="2">We have now entered into one of the most trying times; but also one of the most glorious            times in church history.  Many things are coming upon the world and also upon the church and we (the church) must be totally            prepared to take up our cross daily and venture out into the lost and</font></p>
              <p>  <a href="http://sermon.lighthousechurchinc.org/2011/01/07/special-word-1711-evangelist-barbara-lync h.aspx" target="_parent">Click Here for More</a></p>
            </div>
            <p> </p>
            <div></div>
            <div>
            <!--//              weAddFlash("lhi09hdr.swf",800, 100,"true","true","high","showall","true","#ffffff");              //--></div>
            <div></div>
            <p> </p>
          </div>
          <img src="lighthousegraphic2.jpg" width="960" height="1509" />
          <div id="apDiv20"><img src="myspacebutton.jpg" width="89" height="30" border="0" usemap="#Map3" />
            <map name="Map3" id="Map3">
            <area shape="rect" coords="3,2,87,28" href="http://www.myspace.com/lighthousechurch1" />
          </map>
      </div>
        </div>
      <p> </p>
      </div>
    <!-- end .container --></div>
    <div id="apDiv10"><font size="1"><font color="#FFFFFF">Copyright 2011 The Lighthouse Church Inc.</font></font></div>
    <div id="apDiv11">
      <ul id="MenuBar1" class="MenuBarHorizontal">
        <li><a href="#">Home</a>    </li>
        <li><a href="#" class="MenuBarItemSubmenu">Our Pastor</a>
          <ul>
            <li><a href="#">Fresh Word</a></li>
            <li><a href="#">Itinerary</a></li>
            <li><a href="#">Prophetic Word</a></li>
            <li><a href="#">Sermons</a></li>
            <li><a href="#">Special Words</a></li>
            <li><a href="#">Word of Month</a></li>
          </ul>
        </li>
        <li><a href="#">Men Ministry</a></li>
        <li><a href="#" class="MenuBarItemSubmenu">Ministers</a>
          <ul>
            <li><a href="#">Chris Gore</a></li>
    </ul>
        </li>
        <li><a href="#" class="MenuBarItemSubmenu">Our Church</a>
          <ul>
            <li><a href="#">Contact Us</a></li>
            <li><a href="#">Donate</a></li>
            <li><a href="#">Events</a></li>
            <li><a href="#">Our Store</a></li>
            <li><a href="#">Prayer Request</a></li>
            <li><a href="#">Salvation</a></li>
            <li><a href="#">Subscribe</a></li>
            <li><a href="#">Vision</a></li>
            <li><a href="#">We Believe</a></li>
          </ul>
        </li>
        <li><a href="#" class="MenuBarItemSubmenu">Resources</a>
          <ul>
            <li><a href="#">Prepare for Disaster</a></li>
            <li><a href="#">How to Fast</a></li>
            <li><a href="#">Heaven &amp; Hell</a></li>
            <li><a href="#">Warfare Prayers</a></li>
            <li><a href="#">Wisdom Words</a></li>
          </ul>
        </li>
        <li><a href="#" class="MenuBarItemSubmenu">Prophetic</a>
          <ul>
            <li><a href="#">Article Archive</a></li>
            <li><a href="#">Audio Prophecies</a></li>
            <li><a href="#">Color for Year</a></li>
            <li><a href="#">Major Articles</a></li>
            <li><a href="#">Prophecy Archive</a></li>
            <li><a href="#">Prophetic Articles</a></li>
            <li><a href="#">Word for Year</a></li>
          </ul>
        </li>
      </ul>
    </div>
    <div id="apDiv12"><font size="1"><font color="#FFFFFF">6 South Railroad Ave Wyoming,DE 19934</font></font></div>
    <div id="apDiv13"><font size="1"><font color="#FFFFFF">Phone:(302) 697-1472</font></font></div>
    <script type="text/javascript">
    var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
    </script>
    </body>
    </html>

    Look at all the apdiv's you have.  Those are absolutely positioned layers.  I'm assuming by your post that you are very new to Dreamweaver and HTML and CSS.  I would highly recommend not using absolutely positioned layers until you have a better grasp on HTML and CSS.
    Looking at your code I would suggest that you consider using one of Dreamweaver's built in, or downloadable templates as a starting point and work from there. 
    http://www.adobe.com/devnet/dreamweaver/articles/dreamweaver_custom_templates.html

  • Need help with calculator project for an assignment...

    Hi all, I please need help with my calculator project that I have to do for an assignment.
    Here is the project's specifications that I need to do"
    """Create a console calculator applicaion that:
    * Takes one command line argument: your name and surname. When the
    program starts, display the date and time with a welcome message for the
    user.
    * Display all the available options to the user. Your calculator must include
    the arithmetic operations as well as at least five scientific operations of the
    Math class.
    -Your program must also have the ability to round a number and
    truncate it.
    -When you multiply by 2, you should not use the '*' operator to perform the
    operation.
    -Your program must also be able to reverse the sign of a number.
    * Include sufficient error checking in your program to ensure that the user
    only enters valid input. Make use of the String; Character, and other
    wrapper classes to help you.
    * Your program must be able to do conversions between decimal, octal and
    hex numbers.
    * Make use of a menu. You should give the user the option to end the
    program when entering a certain option.
    * When the program exits, display a message for the user, stating the
    current time, and calculate and display how long the user used your
    program.
    * Make use of helper classes where possible.
    * Use the SDK to run your program."""
    When the program starts, it asks the user for his/her name and surname. I got the program to ask the user again and again for his/her name and surname
    when he/she doesn't insert anything or just press 'enter', but if the user enters a number for the name and surname part, the program continues.
    Now my question is this: How can I restrict the user to only enter 'letters' (and spaces of course) but allow NO numbers for his/her surname??
    Here is the programs code that I've written so far:
    {code}
    import java.io.*;
    import java.util.*;
    import java.text.*;
    public class Project {
         private static String nameSurname = "";     
         private static String num1 = null;
         private static String num2 = null;
         private static String choice1 = null;
         private static double answer = 0;
         private static String more;
         public double Add() {
              answer = (Double.parseDouble(num1) + Double.parseDouble(num2));
              return answer;
         public double Subtract() {
              answer = (Double.parseDouble(num1) - Double.parseDouble(num2));
              return answer;
         public double Multiply() {
              answer = (Double.parseDouble(num1) * Double.parseDouble(num2));
              return answer;
         public double Divide() {
              answer = (Double.parseDouble(num1) / Double.parseDouble(num2));
              return answer;
         public double Modulus() {
              answer = (Double.parseDouble(num1) % Double.parseDouble(num2));
              return answer;
         public double maximumValue() {
              answer = (Math.max(Double.parseDouble(num1), Double.parseDouble(num2)));
              return answer;
         public double minimumValue() {
              answer = (Math.min(Double.parseDouble(num1), Double.parseDouble(num2)));
              return answer;
         public double absoluteNumber1() {
              answer = (Math.abs(Double.parseDouble(num1)));
              return answer;
         public double absoluteNumber2() {
              answer = (Math.abs(Double.parseDouble(num2)));
              return answer;
         public double Squareroot1() {
              answer = (Math.sqrt(Double.parseDouble(num1)));
              return answer;
         public double Squareroot2() {
              answer = (Math.sqrt(Double.parseDouble(num2)));
              return answer;
         public static String octalEquivalent1() {
              int iNum1 = Integer.parseInt(num1);
    String octal1 = Integer.toOctalString(iNum1);
    return octal1;
         public static String octalEquivalent2() {
              int iNum2 = Integer.parseInt(num2);
              String octal2 = Integer.toOctalString(iNum2);
              return octal2;
         public static String hexadecimalEquivalent1() {
              int iNum1 = Integer.parseInt(num1);
              String hex1 = Integer.toHexString(iNum1);
              return hex1;
         public static String hexadecimalEquivalent2() {
              int iNum2 = Integer.parseInt(num2);
              String hex2 = Integer.toHexString(iNum2);
              return hex2;
         public double Round1() {
              answer = Math.round(Double.parseDouble(num1));
              return answer;
         public double Round2() {
              answer = Math.round(Double.parseDouble(num2));
              return answer;
              SimpleDateFormat format1 = new SimpleDateFormat("EEEE, dd MMMM yyyy");
         Date now = new Date();
         SimpleDateFormat format2 = new SimpleDateFormat("hh:mm a");
         static Date timeIn = new Date();
         public static long programRuntime() {
              Date timeInD = timeIn;
              long timeOutD = System.currentTimeMillis();
              long msec = timeOutD - timeInD.getTime();
              float timeHours = msec / 1000;
                   return (long) timeHours;
         DecimalFormat decimals = new DecimalFormat("#0.00");
         public String insertNameAndSurname() throws IOException{
              boolean inputCorrect = false;
                   while (inputCorrect == false) {
                        while (nameSurname == null || nameSurname.length() == 0) {
                             for (int i = 0; i < nameSurname.length(); i++) {
                             if ((nameSurname.charAt(i) > 'a') && (nameSurname.charAt(i) < 'Z')){
                                       inputCorrect = true;
                        else{
                        inputCorrect = false;
                        break;
                        try {
                             BufferedReader inStream = new BufferedReader (new InputStreamReader(System.in));
                             System.out.print("Please enter your name and surname: ");
                             nameSurname = inStream.readLine();
                             inputCorrect = true;
                        }catch (IOException ex) {
                             System.out.println("You did not enter your name and surname, " + nameSurname + " is not a name, please enter your name and surname :");
                             inputCorrect = false;
                        System.out.println("\nA warm welcome " + nameSurname + " ,todays date is: " + format1.format(now));
                        System.out.println("and the time is now exactly " + format2.format(timeIn) + ".");
                        return nameSurname;
              public String inputNumber1() throws IOException {
              boolean inputCorrect = false;
                   while (inputCorrect == false) {
                        try {
                             BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
                             System.out.print("\nPlease enter a number you want to do a calculation with and hit <ENTER>: ");
                             num1 = br.readLine();
                             double number1 = Double.parseDouble(num1);
                             System.out.println("\nThe number you have entered is: " + number1);
                             inputCorrect = true;
                        } catch (NumberFormatException nfe) {
                             System.out.println("\nYou did not enter a valid number: " + "\""+ num1 + "\" is not a number!!");
                             inputCorrect = false;
                        return num1;
         public String calculatorChoice() throws IOException {
              System.out.println("Please select an option of what you would like to do with this number from the menu below and hit <ENTER>: ");
              System.out.println("\n*********************************************");
              System.out.println("---------------------------------------------");
              System.out.println("Please select an option from the list below: ");
              System.out.println("---------------------------------------------");
              System.out.println("1 - Add");
              System.out.println("2 - Subtract");
              System.out.println("3 - Multiply");
              System.out.println("4 - Divide (remainder included)");
              System.out.println("5 - Maximum and minimum value of two numbers");
              System.out.println("6 - Squareroot");
              System.out.println("7 - Absolute value of numbers");
              System.out.println("8 - Octal and Hexadecimal equivalent of numbers");
              System.out.println("9 - Round numbers");
              System.out.println("0 - Exit program");
              System.out.println("**********************************************");
              boolean inputCorrect = false;
                   while (inputCorrect == false) {
                        try {
                             BufferedReader inStream = new BufferedReader (new InputStreamReader(System.in));
                             System.out.print("Please enter your option and hit <ENTER>: ");
                             choice1 = inStream.readLine();
                             int c1 = Integer.parseInt(choice1);
                             System.out.println("\nYou have entered choice number: " + c1);
                             inputCorrect = true;
                        } catch (NumberFormatException nfe) {
                             System.out.println("You did not enter a valid choice number: " + "\""+ choice1 + "\" is not in the list!!");
                             inputCorrect = false;
                        return choice1;
         public String inputNumber2() throws IOException {
              boolean inputCorrect = false;
                   while (inputCorrect == false) {
                        try {
                             BufferedReader br2 = new BufferedReader (new InputStreamReader(System.in));
                             System.out.print("\nPlease enter another number you want to do the calculation with and hit <ENTER>: ");
                             num2 = br2.readLine();
                             double n2 = Double.parseDouble(num2);
                             System.out.println("\nThe second number you have entered is: " + n2);
                             System.out.println("\nYour numbers are: " + num1 + " and " + num2);
                             inputCorrect = true;
                        } catch (NumberFormatException nfe) {
                             System.out.println("You did not enter a valid number: " + "\""+ num2 + "\" is not a number!!");
                             inputCorrect = false;
                        return num2;
         public int Calculator() {
              int choice2 = (int) Double.parseDouble(choice1);
              switch (choice2) {
                        case 1 :
                             Add();
                             System.out.print("The answer of " + num1 + " + " + num2 + " is: " + decimals.format(answer));
                             break;
                        case 2 :
                             Subtract();
                             System.out.print("The answer of " + num1 + " - " + num2 + " is: " + decimals.format(answer));
                             break;
                        case 3 :
                             Multiply();
                             System.out.print("The answer of " + num1 + " * " + num2 + " is: " + decimals.format(answer));
                             break;
                        case 4 :
                             Divide();
                             System.out.print("The answer of " + num1 + " / " + num2 + " is: " + decimals.format(answer));
                             Modulus();
                             System.out.print(" and the remainder is " + decimals.format(answer));
                             break;
                        case 5 :
                             maximumValue();
                             System.out.println("The maximum number between the numbers " + num1 + " and " + num2 + " is: " + decimals.format(answer));
                             minimumValue();
                             System.out.println("The minimum number between the numbers " + num1 + " and " + num2 + " is: " + decimals.format(answer));
                             break;
                        case 6 :
                             Squareroot1();
                             System.out.println("The squareroot of value " + num1 + " is: " + decimals.format(answer));
                             Squareroot2();
                             System.out.println("The squareroot of value " + num2 + " is: " + decimals.format(answer));
                             break;
                        case 7 :
                             absoluteNumber1();
                             System.out.println("The absolute number of " + num1 + " is: " + decimals.format(answer));
                             absoluteNumber2();
                             System.out.println("The absolute number of " + num2 + " is: " + decimals.format(answer));
                             break;
                        case 8 :
                             octalEquivalent1();
                             System.out.println("The octal equivalent of " + num1 + " is: " + octalEquivalent1());
                             octalEquivalent2();
                             System.out.println("The octal equivalent of " + num2 + " is: " + octalEquivalent2());
                             hexadecimalEquivalent1();
                             System.out.println("\nThe hexadecimal equivalent of " + num1 + " is: " + hexadecimalEquivalent1());
                             hexadecimalEquivalent2();
                             System.out.println("The hexadecimal equivalent of " + num2 + " is: " + hexadecimalEquivalent2());
                             break;
                        case 9 :
                             Round1();
                             System.out.println("The rounded number of " + num1 + " is: " + decimals.format(answer));
                             Round2();
                             System.out.println("The rounded number of " + num2 + " is: " + decimals.format(answer));
                             break;
                        case 0 :
                             if (choice2 == 0) {
                                  System.exit(1);
                             break;
                   return choice2;
              public String anotherCalculation() throws IOException {
                   boolean inputCorrect = false;
                   while (inputCorrect == false) {
                             try {                              
                                  BufferedReader br3 = new BufferedReader (new InputStreamReader(System.in));
                                  System.out.print("\nWould you like to do another calculation? Y/N ");
                                  more = br3.readLine();
                                  String s1 = "y";
                                  String s2 = "Y";
                                  if (more.equals(s1) || more.equals(s2)) {
                                       inputCorrect = true;
                                       while (inputCorrect = true){
                                            inputNumber1();
                                            System.out.println("");
                                            calculatorChoice();
                                            System.out.println("");
                                            inputNumber2();
                                            System.out.println("");
                                            Calculator();
                                            System.out.println("");
                                            anotherCalculation();
                                            System.out.println("");
                                            inputCorrect = true;
                                  } else {
                                       System.out.println("\n" + nameSurname + " thank you for using this program, you have used this program for: " + decimals.format(programRuntime()) + " seconds");
                                       System.out.println("the program will now exit, Goodbye.");
                                       System.exit(0);
                             } catch (IOException ex){
                                  System.out.println("You did not enter a valid answer: " + "\""+ more + "\" is not in the list!!");
                                  inputCorrect = false;
              return more;
         public static void main(String[] args) throws IOException {
              Project p1 = new Project();
              p1.insertNameAndSurname();
              System.out.println("");
              p1.inputNumber1();
              System.out.println("");
              p1.calculatorChoice();
              System.out.println("");
              p1.inputNumber2();
              System.out.println("");
              p1.Calculator();
                   System.out.println("");
                   p1.anotherCalculation();
                   System.out.println("");
    {code}
    *Can you please run my code for yourself and have a look at how this program is constructed*
    *and give me ANY feedback on how I can better this code(program) or if I've done anything wrong from your point of view.*
    Your help will be much appreciated.
    Thanks in advance

    Smirre wrote:
    Now my question is this: How can I restrict the user to only enter 'letters' (and spaces of course) but allow NO numbers for his/her surname??You cannot restrict the user. It is a sad fact in programming that the worst bug always sits in front of the Computer.
    What you could do is checking the input string for numbers. If it contains numbers, just reprompt for the Name.
    AND you might want to ask yourself why the heck a calculator needs to know the users Name.

  • Need help with almost completed plugin engine project

    Hi all,
    For a while now I have been working on a plugin engine. After a few iterations, the engine is similar to the Eclipse engine, in that plugins use extension points and extensions to allow contributions. Unlike the eclipse engine I have added the ability for plugins to fire events through the engine and other plugins can add listeners, all through the plugin.xml manifest. Dependencies are mostly handled automatically at plugin load time (when extensions get resolved to extension points, and listeners get resolved to events). For the case where a plugin needs to use classes from another plugin, dependencies are also allowed to be declared. Like the eclipse engine, activation of plugins occurs the first time a class is used within the plugin's classpath, OR a plugin can be activated after it is loaded.
    What I need help with is testing, working on examples to provide with the engine project, and feedback/suggestions before we release the M1 build. I am asking for those that are interested in this type of work to volunteer to help where applicable and possible. I want to provide a solid plugin engine to the java community, one that is easy to use, works well, and is pretty effecient in terms of resource usage and performance.
    Of particular interest to me right at the moment is dealing with multiple versions. As I see it, the engine will be used within an application and as such plugins would be distributed with a specific application version. The plugin version itself is more of a notification as to what version a plugin is, although I imagine it will help when updating at runtime as well.
    Just a few other details of the engine. It handles (or will soon) dynamic load, unload and reload of plugins at runtime. Plugins can be distributed in an archive file format, we call .par (Plugin ARchive), with additional plugin filename extensions configurable at runtime. The plugins can be developed and deployed in an expanded directory format as they are in Eclipse as well, or in the archive format. In the archive format they do not need to be unzipped when deployed, and they can contain embeded jar/zip libraries. The engine handles finding and creating classes directly out of the .par file at runtime.
    Multiple locations to find plugins are configurable before the engine starts, and even after it starts more could be added to allow additional locations to find plugins. URLs are supported, and soon the HTTP protocol will be supported so that plugins can be downloaded and installed at runtime.
    The project can be found at www.sourceforge.net/projects/genpluginengine. If you would like to get involved and help out, please sign up on the dev mail list and send an email to introduce yourself to the rest of the members on the list.
    I'll also add that I am working on a Swing UI Framework built entirely from plugins. It provides a ready-to-launce UI application that developers can simply add their plugins to, extending various extension points of the framework to have menu items, toolbar buttons, status bar access, help and preferences dialog additions, file i/o choosers, tons of open-source components ready to use (or extend to add on to), and like Eclipse, hopefully... draggable window frames that can be dropped on any other frame to form a tabbed frame of windows. Some of this is a ways off, some is getting there now. Presently you can add menu items that do allow plugin activation when first clicked, so plugins can be loaded but not activated until needed. The Preference dialog works but is not completed, and a plugin that adds a plugin control panel to view all loaded plugins, activate them, load/unload/reload, view extension points, extensions, dependencies, etc is partially completed. The point is, to allow a ready to run UI framework in Swing with an easy path for developers to quickly build applications with. If you are interested in this, when you join the mail list and introduce yourself, indicate that you are interested in this as well, as we need help with plugin development for it and would appreciate more help here too.
    Look forward to some replies.

    Might I suggest setting up a project at a known project-site? I've seen your progress and questions posted here from time to time, but one of the drawbacks is that you have to fill each post with the entirity of your vision to explain what you're doing. That's a lot of text to read - and most folks will skip right over it.
    On the other hand, a well-crafted, good-looking project web-site, with appropriate links and docs and vision statements, diagrams, etc. will have more likelyhood of attracting volunteers. java.net and sourceforge.net are likely spots to set up shop. In addition, you get CVS and bug-tracking systems, which can be quite valuable in such a large-scale project where there are lots of pieces.

  • Need help with threads?.. please check my approach!!

    Hello frnds,
    I am trying to write a program.. who monitors my external tool.. please check my way of doing it.. as whenever i write programs having thread.. i end up goosy.. :(
    first let me tell.. what I want from program.. I have to start an external tool.. on separate thread.. (as it takes some time).. then it takes some arguments(3 arguments).. from file.. so i read the file.. and have to run tool.. continously.. until there are arguments left.. in file.. or.. user has stopped it by pressing STOP button..
    I have to put a marker in file too.. so that.. if program started again.. file is read from marker postion.. !!
    Hope I make clear.. what am trying to do!!
    My approach is like..
    1. Have two buttons.. START and STOP on Frame..
    START--> pressed
    2. check marker("$" sign.. placed in beginning of file during start).. on file..
         read File from marker.. got 3 arg.. pass it to tool.. and run it.. (on separate thread).. put marker.. (for next reading)
         Step 2.. continously..
    3. STOP--> pressed
         until last thread.. stops.. keep running the tool.. and when last thread stops.. stop reading any more arguments..
    Question is:
    1. Should i read file again and again.. ?.. or read it once after "$" sign.. store data in array.. and once stopped pressed.. read file again.. and put marker ("$" sign) at last read line..
    2. how should i know when my thread has stopped.. so I start tool again??.. am totally confused.. !!
    please modify my approach.. if u find anything odd..
    Thanks a lot in advance
    gervini

    Hello,
    I have no experience with threads or with having more than run "program" in a single java file. All my java files have the same structure. This master.java looks something like this:
    ---master.java---------------------------------------------------
    import java.sql.*;
    import...
    public class Master {
    public static void main(String args []) throws SQLException, IOException {
    //create connection pool here
    while (true) { // start loop here (each loop takes about five minutes)
    // set values of variables
    // select a slave process to run (from a list of slave programs)
    execute selected slave program
    // check for loop exit value
    } // end while loop
    System.out.println("Program Complete");
    } catch (Exception e) {
    System.out.println("Error: " + e);
    } finally {
    if (rSet1 != null)
    try { rSet1.close(); } catch( SQLException ignore ) { /* ignored */ }
    connection.close();
    -------end master.java--------------------------------------------------------
    This master.java program will run continuously for days or weeks, each time through the loop starting another slave process which runs for five minutes to up to an hour, which means there may be ten to twenty of these slave processes running simultaneously.
    I believe threads is the best way to do this, but I don't know where to locate these slave programs: either inside the master.java program or separate slave.java files? I will need help with either method.
    Your help is greatly appreciated. Thank you.
    Logan

  • Need Help with .nnlp File.............A.S.A.P.

    I'm having a problem also with my JNLP file. I have downloaded the program onto one computer and that computer is using j2re1.4.2_04
    The other computers I believe are all running j2re 1.4.2_05
    I'm not sure if that's make a difference, but on the computer with j2re 1.4.2_05 when going to the site where the .jnlp file is located, the application comes up and says Starting Application. After it gets to that screen it just stays there. I really need help with this as soon as possible.
    Here is my .jnlp file listed below:
    <?xml version="1.0" encoding="utf-8"?>
    <jnlp
      spec="1.0+"
      codebase="http://www.appliedsolutions.com/placewiz"
      href="Placewiz.jnlp">
      <information>
        <title>Placement Wizard 4.0</title>
        <vendor>Applied Solutions, Inc.</vendor>
        <homepage href="index.html"/>
        <description>Placement Wizard 4.0</description>
        <description kind="short">Short description goes here.</description>
        <offline-allowed/>
      </information>
      <resources>
        <j2se version="1.4+"/>
        <j2se version="1.3+"/>
         <j2se version="1.5+"/>
        <jar href="Placewiz.jar"/>
      </resources>
      <security>
          <all-permissions/>
      </security>
      <application-desc main-class="com/asisoftware/placewiz/loader/Exec">
    </jnlp>

    This was due to a change in 1.4.2_05
    the main class attribute
    main-class="com/asisoftware/placewiz/loader/Exec">is wrong - it should be:
    main-class="com.asisoftware.placewiz.loader.Exec">this didnt seem to mater before 1.4.2_05, but some change in java since then caused this bad class specification to stop loading.
    /Andy

Maybe you are looking for

  • Saving Word-11 docs as PDFs, Hyperlinks don't work

    I have a MAC Book Pro running OSX 10.7.3.  I am running Microsoft Word (for compatibility reasons for clients) and need to save documents as PDFs so I can place them on a web site with the hyperlinks active.  When I save as PDF all of the hyperlinks

  • How to use BAPI_SALESORDER_CHANGE to change payment terms in Orders?

    Can any body give me an idea on how to use BAPI_SALESORDER_CHANGE to change payment terms in Orders? Regards, Dantham Conpolwedson

  • Parallel Processing through ABAP program

    Hi, We are trying to do the parallel processing through ABAP. As per SAP documentation we are using the CALL FUNCTION STARTING NEW TASK DESTINATION. We have one Z function Module and as per SAP we are making this Function module (FM)as Remote -enable

  • Business card(s?) stuck in external super drive...

    My external super drive has failed to read any disc I insert.  It attempts to read the disk, sounds like it can't spin it at full speed, and then ejects the disc.  I've tried multiple discs and upon ejecting one, the smallest corner of a business car

  • Locale setting for spanish not working in flex plugin

    I am using the following flex compiler setting in Flex builder 3 and it works fine to support Spanish Locale. -locale=en_US,es_US But the same setting is not working in eclipse installed with flex4 plugin running on flex 3.5 SDK. I am unable to build