Professional Documents
Culture Documents
Task to be done:
1. First create a project with name TempConverter
2. Create a package ‘com.me.temperature’
3. Open package create web application TempConvertWS.java
Algorithm/Flowchart :
1. Open web app in browser.
2. Take user input either degree or Fahrenheit value
3. Press Enter to display the output/result.
4. Code for experiment/practical:
Implementation Code:
package org.me.temperature.
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
/**
*
* @author Jitu
*/
@WebService(serviceName = "TempConvertWS")
public class TempConvertWS {
/**
* This is a sample web service operation
* @param faren
* @return
*/
@WebMethod(operationName = "FtoC")
public float hello(@WebParam(name = "hello")float faren) {
float cel =(float)5/9*(faren-32);
return cel;
}
/**
* Web service operation
* @param cel
* @return
*/
@WebMethod(operationName = "CtoF")
public float hello2(@WebParam(name = "hello1") float cel) {
//TODO write your implementation code here:
float fah = (float)(cel*9)/5+32;
return fah;
}}
Output:
Fahrenheit to Celcius: Celcius to Fahrenheit:
Formula : float cel =(float)5/9*(faren-32); Formula: float fah = (float)(cel*9)/5+32;