0% found this document useful (0 votes)
29 views

Assignment 1 Java

This document contains code for two Java programs. The first program defines constants and variables for Fahrenheit and Celsius temperatures. It uses formulas to convert 212 degrees Fahrenheit to Celsius and vice versa, printing the results. The second program defines a constant for centimeters per inch and converts a given number of inches to centimeters, printing the input and output lengths.

Uploaded by

hh H
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Assignment 1 Java

This document contains code for two Java programs. The first program defines constants and variables for Fahrenheit and Celsius temperatures. It uses formulas to convert 212 degrees Fahrenheit to Celsius and vice versa, printing the results. The second program defines a constant for centimeters per inch and converts a given number of inches to centimeters, printing the input and output lengths.

Uploaded by

hh H
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

WEATHER CONVERTOR:

package javaapplication1;

/**
* @author Rira
*/
public class Convertor {
public static void main( String [] args )
{
//***** 1. declare any constants here
//double x = 0.555;
//int temperature;
double celsius;
int fahrenheit=212;
double fahrenheit1;

celsius= 5.0/9.0*(fahrenheit-32);
// x *(fahrenheit-32);
// ((fahrenheit - 32)*5)/9;

System.out.println("212 degrees fahrenheit is " +celsius +" Celsius degree");


fahrenheit1 = (9.0/5.0)*celsius + 32;
//(1/x)*(celsius+32);

System.out.println( celsius+ "degrees Celsius is " +fahrenheit1 +" fahrenheit degree");

}
}

METRIC LENGHT:
package javaapplication1;

/**
* @author Rira
*/
public class MetricLenght {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
double CPI=2.54;
double INCHES=2;
double Centimeters;
Centimeters=INCHES*CPI;
System.out.println("The inche number is:"+INCHES);
System.out.println("Equivalent Centimeters is:"+Centimeters);
}

You might also like