Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Software Development Software Development
Search Search
Search for:
Tech Support Guy > > >

Java Assignment ... Please Help


(!)

trooper888's Avatar
trooper888 trooper888 is offline
Junior Member with 5 posts.
THREAD STARTER
 
Join Date: May 2007
14-May-2007, 12:04 PM #1
Java Assignment ... Please Help
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
Chicon's Avatar
Chicon Chicon is offline   Chicon has a birthday soon!
Computer Specs
Member with 6,650 posts.
 
Join Date: Jul 2004
Location: 50 34' 07.13" N - 04 10' 23.
Experience: Second socks retriever
14-May-2007, 02:55 PM #2
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.
trooper888's Avatar
trooper888 trooper888 is offline
Junior Member with 5 posts.
THREAD STARTER
 
Join Date: May 2007
14-May-2007, 04:04 PM #3
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
Chicon's Avatar
Chicon Chicon is offline   Chicon has a birthday soon!
Computer Specs
Member with 6,650 posts.
 
Join Date: Jul 2004
Location: 50 34' 07.13" N - 04 10' 23.
Experience: Second socks retriever
14-May-2007, 04:49 PM #4
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:

// with only one statement
   if (myCondition) myStatementOk;
   else myStatementNotOk;

// with manay statements
   if (myCondition) {
      myStatementOk1;
      myStatementOk2;
      ...
   }
   else {
      myStatementNotOk1;
      myStatementNotOk2;
      ...
   }
trooper888's Avatar
trooper888 trooper888 is offline
Junior Member with 5 posts.
THREAD STARTER
 
Join Date: May 2007
14-May-2007, 05:13 PM #5
Thnk you very much ............ all help is appreciated
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
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.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑

Content Relevant URLs by vBSEO 3.3.2