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();
  }
}









Related Tutorials/Questions & Answers:
Is this correct???what are the unnessasary codings here??
ModuleNotFoundError: No module named 'herepy'
Advertisements
ModuleNotFoundError: No module named 'hereby'
Codings - Java Beginners
auto update codings
plz check my codings are correct or not...There is an error..i cant find it..
MAC ADDRESS - Java Beginners
how to convert Visual c++ to java - Java Beginners
c language code
j2me beginner
what is the example of wifi in java
java - JavaMail
ajax with php - Ajax
simple bank application - JSP-Servlet
Character class
How to make a blur text effect, make a blur text effect, blur text effect
java - Java Beginners
Image retrieval from mysql - JSP-Servlet
Equivalent function in java - Java Beginners
java
online voting systems with 10 forms and 3 pages calculations
Solving task 1 by 1 from bundle of task data
doubt in combobox in flex - XML
Securitu - JSP-Servlet
Cross frame menus - Ajax
Dropdown and label issue
AJAX- Database not connected - Ajax
pbml in inserting selected item from combobox into mysql - XML
Simple program to combine all html,ajax,java,servlets,jsp,json - Java Beginners
how to insert the selected item of combobox in mysql - XML
Downloading in JSP - JSP-Servlet
java assignment - Java Beginners
TIBCO Business Studio
multidimensional data cube - Java Beginners
multiple dropdown issue
iphone Window Based Application
JSP and JDBC - JSP-Servlet
servlets And Jsp - JDBC
Book Bank
Null pointer exceptation-Java Servlet web application,Problem connecting with MYSQL database
Programming Help URGENT - JSP-Servlet
java - Java Beginners
Connection pooling - Java Beginners
jsp - Java Interview Questions
iPhone News
Reply - JSP-Servlet
Uploading an image - JSP-Servlet
Program - JSP-Servlet
Open Source CD
Open Source Antivirus

Ads