• Status: Solved
• Priority: Medium
• Security: Public
• Views: 152

# Applet Question : Have an applet and want to print out calculations

Hello,
I was wondering if anyone could answer me this question. I have an applet that works out a calculation based on what the user chooses from a Choice() box. So , say , for example i have
if(choice.getSelectedIndex() == 1)
{
a = (b - (c * a))
}
else if(choice.getSelectedIndex() == 2)
{
b = b * b
}

and so on.
How do I print this out to a seperate frame. ?
I already have a seperate frame already but it is just printing out a or b but not the results.

0
confuddled
• 3
• 2
1 Solution

Commented:
where have you declared a or b?  have you declared them so that wherever you print them to the frame they can be seen so that if a calculation has been made it will be seen by all that are using/need a or b? also try printing out a or b to the console after the calculation has been made to make sure they are changing.
0

Author Commented:
a and b are global variables.
the calculation are defintely changing. I 've checked that using appletviewer. What I asked is not too clear. I'll rephrase this question.

I have the following variables

int Lap;
double Distance, LengthOfPit, totalRaceDistance, FuelPerLap, currentLap, FrontWing, RearWing, DriveT, StopG, distanceLeft, lapsLeft, AmountToFuel, stop1, stop2, stop3, FuelRig,EngineCapacity, safetyLap, yLap, rLap;

and have this following also

else if(ie.getSource().equals((Object)track)) //if the track was selected
{
switch (track.getSelectedIndex())
{
case 0:
//Melbourne
Lap = 58;
Distance = 5.303;
LengthOfPit = 16.0;
totalRaceDistance = Lap * Distance;
currentLap = Clap.getSelectedIndex() + 1;
if (currentLap<=0 || currentLap>58)
{
currentLap = 0;
}
distanceLeft = (totalRaceDistance - (currentLap * Distance));
lapsLeft = distanceLeft / Distance;
AmountToFuel = FuelPerLap * lapsLeft;
break;

etc....................................

I then have this what i want to print out

stop 1 = ((AmountToFuel / FuelRig) + LengthOfPit)

Now what i want to do is print stop1 in a seperate frame. I have no problem creating this frame but i do have a problem printing stop1 to the frame. I hope that cleared it up.

0

Commented:
Have you tried something like,

Label l = new Label( stop.toString() );

Exceter
0

Author Commented:
thanks
0

Author Commented: