Program for Gallons to Liter Conversion in java
import java.io.*;
class Conversion
{
public static void main(String args[])
{
double ans;
for(int i=1;i<=20;i++)
{
ans=i*3.84;
System.out.println(+i+" Gallons = "+ans+"Litres");
}
}
}
Output
1 Gallons = 3.84Litres
2 Gallons = 7.68Litres
3 Gallons = 11.52Litres
4 Gallons = 15.36Litres
5 Gallons = 19.2Litres
6 Gallons = 23.04Litres
7 Gallons = 26.88Litres
8 Gallons = 30.72Litres
9 Gallons = 34.56Litres
10 Gallons = 38.4Litres
11 Gallons = 42.239999999999995Litres
12 Gallons = 46.08Litres
13 Gallons = 49.92Litres
14 Gallons = 53.76Litres
15 Gallons = 57.599999999999994Litres
16 Gallons = 61.44Litres
17 Gallons = 65.28Litres
18 Gallons = 69.12Litres
19 Gallons = 72.96Litres
20 Gallons = 76.8Litres
class Conversion
{
public static void main(String args[])
{
double ans;
for(int i=1;i<=20;i++)
{
ans=i*3.84;
System.out.println(+i+" Gallons = "+ans+"Litres");
}
}
}
Output
1 Gallons = 3.84Litres
2 Gallons = 7.68Litres
3 Gallons = 11.52Litres
4 Gallons = 15.36Litres
5 Gallons = 19.2Litres
6 Gallons = 23.04Litres
7 Gallons = 26.88Litres
8 Gallons = 30.72Litres
9 Gallons = 34.56Litres
10 Gallons = 38.4Litres
11 Gallons = 42.239999999999995Litres
12 Gallons = 46.08Litres
13 Gallons = 49.92Litres
14 Gallons = 53.76Litres
15 Gallons = 57.599999999999994Litres
16 Gallons = 61.44Litres
17 Gallons = 65.28Litres
18 Gallons = 69.12Litres
19 Gallons = 72.96Litres
20 Gallons = 76.8Litres
No comments:
Post a Comment