Thursday, July 23, 2015

Create pyramid in Single For Loop

Hay Guyzzzzzz Today I Show how to create pyramid just in single for Loop

Let's Start


import javax.swing.*;
public class stars{
  public static void main(String args[]){

// now create counter variable
for(int i=1; i<=10; i++)
{
//create to string variable
String str="*";
String str2=str+"\n";
}
Joptionpnae.showMessagedialog(null,"ste2");

// Complete
}
}

Friday, July 17, 2015

Create Table By Using While Loop

Today I show how to using while and how while loop generate table
simple and working java code

Tables In Java


import java.util.Scanner;
public class tables{
  public static void main(String args[]){

       Scanner input = new Scanner(System.in);
       System.out.println("Enter your Table number");
       int n=input.nextInt();
       int Counter =1;
   
     while(counter<=10){
       
       System.out.println(n+" * "+ counter+" = "+n*counter);
       counter++;
}
}
}

Complete Program