Simple calculation programs


Program to calculate the celcius if given f is 20. Given program will calcuate the celcius if the Fahrenheit is given. Fahrenheit is initialized already.

class Celsius
{
public static void main(String args[])
{
int f = 20;
float c;
System.out.println("F is : "+f);
c = (f - 32)/1.8f;
System.out.println("Celcius is : "+c);
}
}



Program to display the reverse of 125 without loop.


class ReverseDigit
{
public static void main(String args[])
{
int n,r;
n = 125;
r = n%10;
System.out.print(r);
n = n / 10;
r = n % 10;
System.out.print(r);
n = n / 10;
r = n % 10;
System.out.print(r);
}
}

0 Comments:

Post a Comment