1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Java Assignment ... Please Help

Discussion in 'Software Development' started by trooper888, May 14, 2007.

Thread Status:
Not open for further replies.
Advertisement
  1. trooper888

    trooper888 Thread Starter

    Joined:
    May 11, 2007
    Messages:
    5
    my whole class is so stuck with this, can someone please do it, its quit basic for most of the programmers on here

    ***Note

    *We use Kawa 5.0 to run our programs
    *please use methods and call each method as its needed
    * Please use JOptionPane for message boxes

    Heres the assignment

    http://usera.imagecave.com/killswitch/jjjjjjjj.gif

    i would be so greatful ... thanks in advance
     
  2. Chicon

    Chicon

    Joined:
    Jul 29, 2004
    Messages:
    6,650
    Hi trooper888 ,

    Welcome to TSG ! :)

    I suggest you to start first your application by making a design of your GUI and its components.
    For example :
    - a resizable frame for the user (because it must be friendly) as the main container,
    - a titled panel containing a set of 2 radio buttons for the wished currency (euro, pound),
    - a label and a writable text box to insert the wished amount of money,
    - a label and a protected text box to display the money converted in pounds,
    - a label and a protected text box to display the number of gallons,
    - a label and a protected text box to display the number of litres,
    - a label and a protected text box to display the mileage,
    - a button that will be used to compute,
    - a button that will be used to reset the inputs and outputs,
    - eventually a button to exit the application

    After that, you build a diagram that describes the wished behaviour of your GUI (if you're familiar with UML, it is called a use case diagram).

    For example :
    Step 1 When the user runs the program, a frame opens. The frame is centered and sizes 2/3 of the user's screen. The frame is resizable. The X button on the right top is enabled to stop the program.
    Step 2 The user has the choice of euros or pounds as the currency with a set of 2 radio buttons. Default is set to euros.
    Step 3 There's a input box that allows only numeric entries including eventually a decimal point followed by 2 decimals. The user must fill the input box with the wished amount of money
    ...
    ...
    ... and so on

    And when you're done with all that stuff, then you can think about the coding.
    If you're following my example, you've at least one constructor to initialize your frame and six methods treating the events (the 2 radio buttons, the input box and the 3 buttons).
    The Exit button is the more easy. ;)
     
  3. trooper888

    trooper888 Thread Starter

    Joined:
    May 11, 2007
    Messages:
    5
    Aww Thanks a million mate.......... and thanks for the warm wellcome, i like this board already

    Oh, fortunately im using the JOptionPane thingy so i dont need to create any of the GUI components , just use them . lol its just the code im having some troubles with

    Heres what ive got so far ....... Youl notice im editing some stupid code for triangles so bits of it arent relevant including the comments lol please try and ignore that ...

    problem is i dont have the software and cant test it + Plus im a little stuck now

    Side 1 = SoE
    Side 2 = Sterling
    Side 3 = Euro

    import uuInOut;
    import javax.swing.JOptionPane;

    class TestTriangle2
    {
    static double SoE,Sterling,Euro, ResultSterling; // to hold the three values

    String SoE;

    static void ReadSides()
    { // to prompt for and read in the three values
    JOptionPane.showInputDialog("Enter 1 to pay in Sterling, 2 To paying euro and 3 To Exit:" );
    SoE = uuInOut.ReadDouble();

    } // ReadSides

    static boolean ValidTriangle()
    { // to check if sides are valid
    if (SoE = 1 ||
    JOptionPane.showInputDialog("Enter the ammount you would like to pay for in sterling:" );
    Sterling = uuInOut.ReadDouble();
    else
    JOptionPane.showInputDialog("Please enter the ammount you would like to pay for in Euro:" );
    Euro = uuInOut.ReadDouble();
    } //

    static void DisplayTriangleType()
    { // to display what kind of triangle
    if (SOE == Sterling)
    Result1 = Sterling
    JOptionPane.showMessageDialog( null,"The ammount in Sterling is " + result1 );
    else
    Result1 = Euro * 1.5
    JOptionPane.showMessageDialog( null,"The ammount in sterling is " + result );
    } // DisplayTriangleType

    public static void main(String[] args)
    { ReadSides();
    if (!ValidTriangle())
    System.out.println("These do not make a valid triangle");
    else DisplayTriangleType();
    }// main method

    }// class TestTriangle2
     
  4. Chicon

    Chicon

    Joined:
    Jul 29, 2004
    Messages:
    6,650
    There's a double declaration of the variable SoE in the following lines :


    class TestTriangle2
    {
    static double SoE,Sterling,Euro, ResultSterling; // to hold the three values

    String SoE;


    In the following lines, SOE and Result1 are not declared :


    if (SOE == Sterling)
    Result1 = Sterling


    Also, the proper way to use an if ... else statement :

    Code:
    [SIZE=2]
    // with only one statement
       if (myCondition) myStatementOk;
       else myStatementNotOk;
    
    // with manay statements
       if (myCondition) {
          myStatementOk1;
          myStatementOk2;
          ...
       }
       else {
          myStatementNotOk1;
          myStatementNotOk2;
          ...
       }
    [/SIZE]
     
  5. trooper888

    trooper888 Thread Starter

    Joined:
    May 11, 2007
    Messages:
    5
    Thnk you very much ............ all help is appreciated
     
  6. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/573333