Shadow Blade
Morrowland Presents Apron Tutorials
game - design - multimedia - web - programming - tutorials - There are currently viewers visiting Apron Tutorials.
   
 
TECHNICAL
GRAPHICAL
SOUND
GAME
WEB
ARTICLE
TOOL
PROJECT
 
 NEWS

  news

  history


 TECHNICAL TUTORIALS

  opengl

  direct3d

  c/c++

  visual basic

  java

  c#


 WEB TUTORIALS

  html

  dhtml

  asp

  php


 IMAGE EDITING

  photoshop

  draw sketch


 3D MODELING

  3d studio


 PROJECTS

  shadow blade

  game environment

  virtual 3d guide

  billy blue flame


 DEMOS

  win32 api


 ARTICLES

  general

  opengl


 COMMUNITY

  about us

  credit

  contact













import java.io.*; // import java.io package

public class Class1
{
	// our main function
	public static void main (String [] args) throws java.io.IOException
	{
		int value = 0;

		System.out.println("How many cars do you have?"); //Question?

		// inputBuffer
		BufferedReader inKeyBoard;
		inKeyBoard = new BufferedReader(new InputStreamReader(System.in));
		value = Integer.valueOf(inKeyBoard.readLine()).intValue();


		//This is a if else test
		if(value > 0) // if Value more than 0
		{
		  System.out.println("Ok.."); // Thats OK!
		}
		else // else value is less or equal to 0
		{
		  System.out.println("So you don't have a car."); // then no car
		}


		// if test
		if(value < 0)
		{
		  //if the value is negative
		  System.out.println("And you have a loan..");
		}


		// if test
		if(value == 1) // if the value = 1
		{
		  System.out.println("You have a car!");
		}


		// This is called an in-line if test, with no brackets '{}'.
		// if value = 2
		if(value == 2) System.out.println("You have two cars!");


		// You can also write an if in one line like this
		// more than 3 cars shuld make you rich
		if(value > 3) System.out.println("Are you rich?");
	}
}

// The IF statement is the first thing i learned in programming.
// IF? is your questions to the application, so that you can
// decide what is going to happen next..

// if a counter is 10 then set it back to 0
// if you don't have any money left, you can't buy that dvd-player.
// if your character fall more than 3 meters in a game,
// then he loses energy etc.


//sometimes you just need one if statement
//
//		if (?)
//		{
//
//		}


//sometimes you ned two or more if statements
//
//		if (question1?)
//		{
//
//		}
//
//		if (question2?)
//		{
//
//		}


//sometimes it is easier to use if else
//
//		if(?)
//		{
//
//		}
//		else
//		{
//
//		}


//sometimes it is easier to use if   else if
//		if(question1?)
//		{
//
//		}
//		else if(question2?)
//		{
//
//		}

// I have tried to demonstrate different ways to write if tests
// It all depend on the "situation", and how you prefer to do your programming..




Download The Source Code! Download Java Source Code


I hope you found this java tutorial useful!

Don't forget to mention Apron Tutorials in your References!

Best Regards
Ronny André Reierstad

 LINKS

  morrowland home



 GAME DEVELOPEMENT

  nvidia

  gamedev

  polycount


 PROJECTS

  shadow blade

  game environment

  virtual 3d guide

  billy blue flame


 MATH AND PHYSICS

  mathworld

  physicsworld







PLEASE LINK TO


  All rights reserved Morrowland © 2011  
Ronny André Reierstad