Thursday, July 21, 2011

Covertion - meters to yard

package meters.to.yard;
import java.io.*;
 

public class MetersToYard {

   
    public static void main(String[] args) throws IOException {
        // 1 meter = 1.0936133 yard
      
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
       
  System.out.println("Enter the meter:");
  int meter = Integer.parseInt(bf.readLine());
  double yard = meter * 1.0936133;
  System.out.println("Meter: " + meter);
  }
}

Tuesday, July 19, 2011

Conversion - Kg to Pds

package kg.to.pounds;
import java.io.*;
public class KGToPounds {

    public static void main(String[] args) throws Exception {
        //1 kilograms = 2.20462262 puonds;
          BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

         
  System.out.println("Enter the Kilogram:");
  int kilo = Integer.parseInt(bf.readLine());
  double pound = kilo * 2.20462262;
  System.out.println("Pounds: " + pound);
  }
}

Sunday, July 17, 2011

D i D Y O U K N O W THAT ..

ex. shoe :)



import java.util.Scanner;

public class Shoe {

    public String brand;
    public int model;
    public String type;
    public String color;
    public double size;

    public void displayBrand(){
        System.out.println("The brand of your shoes is "+brand);
    }
    public void displayModel(){
        if(model<2011){
        System.out.println("You have an old model of shoes ");
        } else {
        System.out.println("You have  the latest model of shoes ");
        }
      }

    public void displayType(){
        System.out.println("Your shoes is a "+ type);
    }
    public void displayColor(){
        System.out.println("The color of your shoes is "+ color);
    }
    public void displaySize(){
        System.out.println("The size of your shoes is "+size);
    }

}

-------------------------------------------





import java.util.Scanner;


public class ShoesImp {

    public static void main(String[] args) {

    Scanner input = new Scanner(System.in);
        Shoe Shoe = new Shoe();


        System.out.println("What is the brand of your shoes: ");
        String brand = input.next();

        System.out.println("What year is the model of your shoes: ");
        int model = input.nextInt();

        System.out.println("What is the type of your shoes: ");
        String type = input.next();

        System.out.println("What is the color of your shoes: ");
        String color = input.next();

        System.out.println("What is the size of your shoes: ");
        int size = input.nextInt();


        Shoe.brand = (brand);
        Shoe.model = (model);
        Shoe.type = (type);
        Shoe.color = (color);
        Shoe.size = (size);

        System.out.println();
        System.out.println();
        System.out.println();

        Shoe.displayBrand();
        Shoe.displayModel();
        Shoe.displayType();
        Shoe.displayColor();
        Shoe.displaySize();


    }

}

ex. of 'Vehicle' program [Imp]

public class Vehicle {
    public String type;
    public String make;
    public String color;
    public int year;
    public void displayType(){
        System.out.println("Your vehicle is of type :"+ type);
        }
    public void displayMake(){
        System.out.println("It was made by :"+ make);
        }
    public void displayColor(){
        System.out.println("Wow it's color is "+ color);
        }
    public void displayYear(){
        if (year<2007){
        System.out.println("Your vehicle is old model");
        } else{
        System.out.println("wow you own a latest model of vehicle");
   }
 }


}

---------------------------------------------------------------

import java.util.Scanner;

public class VehicleImp {
    public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    Vehicle Vehicle= new Vehicle();

    System.out.print("What is the type of the vehicle: ");
    String type = input.next();

         System.out.print("What Brand is the vehicle: ");
         String make = input.next();

         System.out.print("What is the color of the vehicle: ");
         String color = input.next();

         System.out.print("What year was it made: ");
         int year = input.nextInt();

         Vehicle.type = (type);
         Vehicle.make = (make);
         Vehicle.color = (color);
         Vehicle.year = (year);

         Vehicle.displayType();
         Vehicle.displayMake();
         Vehicle.displayColor();
         Vehicle.displayYear();
    }


}