Jun 15 2009

Simple Methods

Category: Javaadmin @ 11:23 am

public class methods {
	public static void main (String[] args)
 
	{
 
	 addition ();
	 multiplication ();	
 
	}
 
	public static void addition()
 
	{
		int no1 = 10;
		int no2 = 15;
		int add = no1+no2;
		System.out.println(add);
	}
 
	public static void multiplication()
 
	{
		int no3 = 12;
		int no4 = 10;
		int mul = no3*no4;
		System.out.println(mul);
	}
}

Tags: , , ,


Jun 11 2009

Temp Converter

Category: Javaadmin @ 12:19 am


//Purpose: Convert a Celsius temperature to Fahrenhit
 
public class tempConverter {
	public static void main(String[] args){
 
		float celsius = 100;
		float fahrenheit;
 
		//convert to Fahrenheit equivalent
		fahrenheit = 32 + ((9* celsius) / 5);
 
		System.out.println("Celsius temperature");
		System.out.println("  " + celsius);
		System.out.println("Equivalent Fahrenheit temperature");
		System.out.println("  " + fahrenheit);
		}
}

Tags: , ,


Jun 09 2009

The difference between print and println

Category: Javaadmin @ 10:51 pm

  • Cursor stays on the same line when we use “print” command.
  • Cursor goes to the following  line when we use “println” command.


/*This program shows the difference between
  print and println
*/
 
public class secondFile{
 
	public static void main(String[] args)
	{
 
		System.out.print("Java is a very protable language ");
		System.out.println("and can run different types of computers.");
		System.out.println("This is the next line !!!");
	}
}

Tags:


« Previous PageNext Page »