Is this correct???what are the unnessasary codings here??

Is this correct???what are the unnessasary codings here??

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);
  }
}
View Answers

March 1, 2011 at 11:12 AM

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









Related Tutorials/Questions & Answers:
Is this correct???what are the unnessasary codings here??
ModuleNotFoundError: No module named 'hereby'
Advertisements
ModuleNotFoundError: No module named 'herepy'
auto update codings
plz check my codings are correct or not...There is an error..i cant find it..
c language code
j2me beginner
what is the example of wifi in java
simple bank application - JSP-Servlet
java
online voting systems with 10 forms and 3 pages calculations
Character class
How to make a blur text effect, make a blur text effect, blur text effect
Solving task 1 by 1 from bundle of task data
Dropdown and label issue
java assignment - Java Beginners
Book Bank
multiple dropdown issue
iPhone News
Null pointer exceptation-Java Servlet web application,Problem connecting with MYSQL database
JavaTutorials

Ads