Pesos

Publicado por Romulo 03/09/2003

[ Hits: 4.486 ]

Download ShowWeight.java




Script que recebe um valor através de um parâmetro enviado ao applet via html e exibe em diferentes medidas.

não esqueça de criar um arquivo html contendo:

<applet code="ShowWeight.class" height="170" width="250">
<param name="person" value="Higor">
<param name="weight" value="80">
</applet>

  



Esconder código-fonte

import java.awt.*;

public class ShowWeight extends java.applet.Applet
{
    float lbs = (float)0;
    float ozs;
    float kgs;
    float metricTons;
    
    String name = "SomeBody";
    
    public void init()
    {
   String lbsValue = getParameter("weight");
   if (lbsValue != null)
   {
       Float lbsTemp = Float.valueOf(lbsValue);
       lbs = lbsTemp.floatValue();
   }
   
   String personValue = getParameter("person");
   if (personValue != null)
       name = personValue;
       
   ozs = (float)(lbs * 16);
   kgs = (float)(lbs / 2.204623);
   metricTons = (float)(lbs / 2204.623);
    }
    
    public void paint(Graphics screen)
    {
   screen.drawString("Studyint the weight of "+ name, 5,30);
   screen.drawString("In pounds: " + lbs, 55,50);
   screen.drawString("In ounces: " + ozs, 55,70);
   screen.drawString("in Kilograms: " + kgs, 55,90);
   screen.drawString("In metric tons: " + metricTons, 55,110);
    }
}

Scripts recomendados

_l0k0_

Gerador de nicks

AMIGAAAAAAAA

Texto estilo gangorra

Menu colorido


  

Comentários

Nenhum comentário foi encontrado.


Contribuir com comentário




Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts