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 !!!");


Jun 08 2009

A Simple Java Program

Category: Javaadmin @ 12:43 pm

Writing the First Java Program

This is a simple Java Program.
Call this file “Example.java”
class Example {
	public static void main(String args[]){
		System.out.println("This is a simple Java program.");

Compiling the Program

To Compile the Example program, execute the compiler, javac, specifying the name of source file as showed below,

Let’s assume that source file is located at D:\>java\Example.java

Go to Command prompt & type: at D:\>java\javac Example.java

The javac compiler creates a file called Example.class that contains bytecode version of the program, That can Be executed by Java virtual Machine.

To actually run the program you must use java application launcher, called “java”.
To do so in command prompt Type,
D:\>java\java Example

When the program run, the following output is displayed:
” This is a simple Java program. “

Tags: ,

« Previous Page