Combination of Array, for loop and if statement. You can get more knowledge in this program. Basic program using java that gives alot of lesson to a begginer like you :-).

You can donwload my sample program below.
Download File
Planet Source Code(vb6.0, vb.net, Java, Php, Asp, Excel, Access)
do while statement is one of loop statement in Php that
has a specific condition depending the program flows basically do while loop and while loop
are commonly the same but deffirent format of coding. The same with while loop that do while
statement will automatically stop if the condition becomes false.
Example:
You can download my example below.
Download File
while statement is one of loop statement in Php that
has a specific condition depending the program flows. The while loop
statement will automatically stop if the condition becomes false for
example if you creating a simple program displaying numbers the
while loop statement will stop displaying numbers base in a given value
or the count of the loop on how many times the loop repeat.
code to be executed;
Example:
$i=1;
while($i<=10)
{
echo "The number is " . $i . "
";
$i++;
}
Output:
The number is 1
The number is 2
The number is 3
The number is 4
The number is 5
Download File
Very nice example for switch statement.
If have many blocks and if you want to select one of you blocks actually you can use Switch statement.
The switch statement is used to shorting the code i mean the block of code instead using if..else..elseif.
Syntax:
The switch statement
switch (expression)
{
case label1:
code to be executed if expression = label1;
break;
case label2:
code to be executed if expression = label2;
break;
default:
code to be executed
if expression is different
from both label1 and label2;
}
Example:
switch ($x)
{
case 1:
echo "Index 1 ";
break;
case 2:
echo "Index 2";
break;
case 3:
echo "Index 3";
break;
default:
echo "No number between 1 and 3";
}
If the value of variable $x is 2 the output is
Output:
Index 2
$names[0] = "John";
$names[1] = "Mario";
$names[2] = "Merbert";
echo $names[1] . " and " . $names[2] . " are ". $names[0] . "'s neighbors";
?>
You can the element or the value of the array using there indeces or index.
Example:
echo $name[2];
Output:
Mario
Download File
Proper Format
$var_name = value;
Example:
//Open parameter
$txt = "Hello World!";
$number = 25;
$echo($txt . "
");
$echo($number);
?> //Closing parameter
Ouput:
Hello word
25
Download File