import java.util.Scanner; public class Length { public int meters; public int centiMeters; public double yards; public double feet; public double inches; public double newMeter; public void read() { Scanner kbd=new Scanner(System.in); System.out.print("Enter the meters = "); meters=kbd.nextInt(); System.out.print("\n"); System.out.print("Enter the centi meters = "); centiMeters=kbd.nextInt(); System.out.print("\n"); } public void display() { System.out.printf("Lenth of an object = %dm %dCm\n",meters,centiMeters); } public void convert() { newMeter=meters+(centiMeters/100.0); yards = (newMeter)*1.09361; System.out.printf("Lenth in Yards = %s",yards); System.out.print("\n"); feet = (newMeter)*3.28084; System.out.printf("Lenth in Feets = %s",feet); System.out.print("\n"); inches = (newMeter)*39.37; System.out.printf("Lenth in Inches = %s",inches); } }
import java.util.Scanner; public class Length { public int meters; public int centiMeters; public double yards; public double feet; public double inches; public double newMeter; public void read() { Scanner kbd=new Scanner(System.in); System.out.print("Enter the meters = "); meters=kbd.nextInt(); System.out.print("\n"); System.out.print("Enter the centi meters = "); centiMeters=kbd.nextInt(); System.out.print("\n"); } public void display() { System.out.printf("Lenth of an object = %dm %dCm\n",meters,centiMeters); } public void convert() { newMeter=meters+(centiMeters/100.0); yards = (newMeter)*1.09361; System.out.printf("Lenth in Yards = %s",yards); System.out.print("\n"); feet = (newMeter)*3.28084; System.out.printf("Lenth in Feets = %s",feet); System.out.print("\n"); inches = (newMeter)*39.37; System.out.printf("Lenth in Inches = %s",inches); } public static void main(String[]args){ Length l=new Length(); l.read(); l.display(); l.convert(); } }
Ads