Program to accept the value of temperature in Celsius using param tag and display the temperature in Fahrenheit on Applet

In this program, we pass temperature in Celcius as a parameter to applet and get it in applet's init( ) method to convert it in Fahrenheit. After that we will display the result on applet. The formula for the conversion from Celcius to Fahrenheit is given below:
temp_in_fah = temp_in_cel * 1.8 + 32
To convert temperatures in degrees Celsius to Fahrenheit, multiply by 1.8 (or 9/5) and add 32. For example: 15°C * 1.8 + 32 = 59°F


PROGRAM
import java.awt.*;  // import awt package
import java.applet.*; // import applet package

public class CelsiFahrApplet extends Applet 
{
    String msg;
    float celsius,fahrenheit;
    
    public void init() // override init() method
    {
        msg = getParameter("Temp");  // receiving parameter value
        celsius = Float.parseFloat(msg); // Convert string to int
        System.out.println(celsius);
        fahrenheit = (1.8f * celsius)+32; // Formula F = ((9/5)*C)+32
    }
    
    public void paint(Graphics g)
    {
        g.drawString("Temperature in Fahrenheit = "+fahrenheit,10,50); // display message on applet
    }
}
/*  <applet code=CelsiFahrApplet.class height=100 width=300>
  <param name="Temp" value="15">
 </applet>*/
OUTPUT 

C:\>javac CelsiFahrApplet.java 
C:\>appletviewer CelsiFahrApplet.java



Comments

  1. You can find several different sorts of Temperature converter, so every one of which contains its own own intent. At the United States, the Fahrenheit scale is most commonly utilised (for example ) to record temperatures from the headlines headlines ). You are going to find it utilised if pharmacies, banks, etc.. . examine that the afternoon's fever on digital indications in your roads. It's a convenient extension for scientific query plus it's used across the globe. Other significant temperatures scale is currently Fahrenheit that's used chiefly in United States. The system for converting from Celsius to Fahrenheit is much more complex.I'm utilizing this fever converter and earn the maximum correct conversions immediately, depending on some fever scales. The worthiness at Fahrenheit might be gotten by multi ply Celsius worth by 1.8 then add 3 2. H2o freezing position are currently in 32 Fahrenheit. The very Optimal/optimally way to Have the conversion performed would be always to utilize an Internet fever converter When the temperatures drops exceeding 0 amounts, the water molecules have been losing rate, the fascination between these is slowly developing and they crystallize forming ice. We are all aware the drinking water volume is steadily currently rising after freezing. That is really since the hydrogen molecules have been exercising a fantastic allure which makes the drinking water molecules have to be ordered in a particular placement, which makes spaces between these, and also hence causing the quantity be higher compared to the amount of atoms would be the exact same.

    ReplyDelete
  2. We have sell some products of different custom boxes.it is very useful and very low price please visits this site thanks and please share this post with your friends. humidity chamber

    ReplyDelete

Post a Comment

Popular posts from this blog

Program to define a class 'employee' with data members as empid, name and salary. Accept data for 5 objects using Array of objects and print it.

Program to input age from user and throw user-defined exception if entered age is negative

Define a class Student with four data members such as name, roll no.,sub1, and sub2. Define appropriate methods to initialize and display the values of data members. Also calculate total marks and percentage scored by student.