Thursday, 10 May 2012

Whether given no. is Armstrong or not



/*Write a program to find whether given no. is Armstrong or not. 

 Example :           Input - 153       

 Output - 1^3 + 5^3 + 3^3 = 153, so it is Armstrong no. */

class Armstrong{
      public static void main(String args[]){
      int num = Integer.parseInt(args[0]);
      int n = num; //use to check at last time

Tuesday, 8 May 2012

Convert given no. of days into months and days



/* Write a program to convert given no. of days into months and days.

  (Assume that each month is of 30 days)

  Example :         

  Input - 69  

 Output - 69 days = 2 Month and 9 days */

Program to generate a Triangle



/*Write a program to generate a Triangle.

 eg:

  1
  2 2
  3 3 3
  4 4 4 4

 and so on as per user given number */

class Triangle{
      public static void main(String args[]){

Program to Swap the values



/* Write a program to Swap the values */

class Swap{
      public static void main(String args[]){
      int num1 = Integer.parseInt(args[0]);
      int num2 = Integer.parseInt(args[1]);
      System.out.println("\n***Before Swapping***");
      System.out.println("Number 1 : "+num1);
      System.out.println("Number 2 : "+num2);

Program to Display Multiplication Table



/* Program to Display Multiplication Table */

class MultiplicationTable{
      public static void main(String args[]){
      int num = Integer.parseInt(args[0]);
      System.out.println("*****MULTIPLICATION TABLE*****");