Go to Top

Monday 28 November 2011

Utilities 23 : Number to Word Converter

Hello friends ! Today I am going to present a unique Number to Word Converter, made in Java. This will allow you to convert any number, long, short, very long, negative, decimal etc. to words in the Indian notation. For example :

Sample input : 132433

Sample output : One lakh thirty two thousand four hundred thirty three only.

This project is still under development, but I assure you very less and minor errors. In case of any error, please report it to us in the comments section.

To view the program, simply click on the link below :

View Here

To download the program, simply click on the link below : 


Friday 25 November 2011

To print the given pattern

Question 69 : Write a program in Java to print the given pattern : 

    *****
   *       *
  *         *
 *           *
*             *
 *           *
  *         *
   *       *
    *****

(Spacing in Blogger is not as in Java. Note that spacing inside the hexagon is in the order : 5, 7, 11, 13, 11, 7, 5)

Java Program :

class pattern_39
{
 static void print(int n)
 {
     int i,j,k,m=0;
     for(i=1;i<n;i++)
     System.out.print(" ");
     for(i=1;i<=n;i++)
     System.out.print("*");
     System.out.print("\n");
     for(i=1;i<n;i++)
     {
         for(j=1;j<(n-i);j++)
         System.out.print(" ");
         System.out.print("*");
         m=(n+(i*2-1));
         for(k=1;k<m;k++)
         System.out.print(" ");
         System.out.print("*");
         System.out.print("\n");
        }
        m=m-1;
        for(i=1;i<n-1;i++)
     {
         for(j=1;j<=i;j++)
         System.out.print(" ");
         System.out.print("*");
         for(k=1;k<(m-(i*2-1));k++)
         System.out.print(" ");
         System.out.print("*");
         System.out.print("\n");
        }
     for(i=1;i<n;i++)
     System.out.print(" ");
     for(i=1;i<=n;i++)
     System.out.print("*");
    }
}
         

Thursday 24 November 2011

To print the given pattern

Question 68 : Write a program in Java to print the given pattern : 

ABCDEFEDCBA
ABCDE  EDCBA
ABCD       DCBA
ABC             CBA
AB                   BA
A                         A

(Spacing in Blogger is not as in Java. Note that spacing is in the order : nil, 1, 3, 5, 7...)

Java Program :

class pattern_37
{
 static void pattern(int len)
 {
     int n=65,i,j,k;
     String j1="";
     for(i=len;i>=1;i--)
     {
         n=65;
         for(j=0;j<i;j++)
         System.out.print((char)(n+j));
         System.out.print(j1);
         j1=j1+"  ";
         for(k=i-1;k>=0;k--)
         {
             if(i==len && k==i-1)
             k=k-1;
            System.out.print((char)(n+k));
        }
         System.out.print("\n");
         if(i==len)
         j1=" ";
        }
    }
}

Monday 21 November 2011

Utilities 22 : Advanced Telephone E-Billing System

These days, I was busy with this program, so I had less time for blogging. But as faithful readers, you have the right to see how this program works. This is an E-Billing system, with many features. See the help topics on the program for help.

So I am going to share my whole Computer Science Project with you. It contains an additional five programs and total documentation for the E-Billing program.

For the whole project :



For only the E-Billing program :



Saturday 19 November 2011

To find the sum of even and odd numbers

Question 68 : Write a program in Java to find the sum of odd and even numbers between a range.

Java Program : 

public class sum_range
{
 int e,o,l,u;
 public sum_range(int lower_limit,int upper_limit)
 {
     l=lower_limit;
     u=upper_limit;
     e=0;
     o=0;
     sum();
     display();
    }
    public void sum()
    {
        for(int i=l;i<=u;i++)
        {
            if(i%2==0)
            even(i);
            else
            odd(i);
        }
    }
    public void odd(int a)
    {
        o=o+a;
    }
    public void even(int a)
    {
        e=e+a;
    }
    public void display()
    {
        System.out.print("The sum of even numbers : "+e);
        System.out.print("\nThe sum of odd numbers : "+o);
    }
}
    

Wednesday 16 November 2011

Utilities 21 : Java Simple Virus

Start it and it will keep going on.

Java Program :

class virus
{
 static void main()
 {
     for(;;)
     {}
    }
}

Wednesday 9 November 2011

To find the area of a rectangle

Question 67 : Write a program in Java to find the area and perimeter of a rectangle. Length and breadth to be taken as input from the user.

Java Program :

public class rectangle
{
 public static void main(int l,int b)
 {
     int a=0,p=0;
     a=l*b;
     p=2*(l+b);
     System.out.println("Area of the rectangle = "+a+" units");
     System.out.println("Perimeter of the rectangle = "+p+" units");
    }
}

Friday 4 November 2011

To print all the factors of a number

Question 67 : Write a program in Java to print all the factors of a number.

Java Program :

import java.io.*;
class factors
{
 static void main()throws IOException
 {
     BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
     int a,i;
     System.out.print("Enter the number : ");
     a=Integer.parseInt(buf.readLine());
     System.out.print("\n");
     System.out.print("The factors are : ");
     for(i=1;i<=a/2;i++)
     {
         if(a%i==0)
         System.out.print(i+",");
        }
        System.out.print(a);
    }
}

To find the solution of a quadratic equation

Question 67 : Write a program in Java to find the solution of a quadratic equation by taking the inputs of a,b,c from the user.

Java Program :

import java.io.*;
class quadratic
{
 static void main()throws IOException
 {
     BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
     int a,b,c;
     double d,e;
     System.out.println("The format of a quadratic equation is given as follows : ");
     System.out.println("\nax2 + bx + c = 0");
     System.out.println("\nEnter values for a,b,c as follows : ");
     System.out.print("\na = ");
     a=Integer.parseInt(br.readLine());
     System.out.print("\nb = ");
     b=Integer.parseInt(br.readLine());
     System.out.print("\nc = ");
     c=Integer.parseInt(br.readLine());
     d=((-1*b)+java.lang.Math.sqrt((b*b)-(4*a*c)))/(2*a);
     e=((-1*b)-java.lang.Math.sqrt((b*b)-(4*a*c)))/(2*a);
     System.out.print("\nEquation : "+a+"x2");
     if(b<0)
     System.out.print(b+"x");
     else
     System.out.print("+"+b+"x");
     if(c<0)
     System.out.print(c);
     else
     System.out.print("+"+c);
     System.out.print(" = 0");
     System.out.println("\n\nSolution : x = ( "+d+" , "+e+" )");
    }
}
   

Wednesday 2 November 2011

Utilities 20 : Old style calculator

This is a kind of an old style calculator. You have to enter a number then enter the sign then the number and so on. This isn't one of my best programs, but it doesn't pay to hide it.

Java Program :

import java.io.*;
class calculator_working_edition
{
 static void main()throws IOException
 {
     BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
     double a,b=0;
     String q;
     char o='a',opt='b';
     System.out.println("\t\t*****Calculator*****\n");
     System.out.print("Enter the number : ");
     a=Double.parseDouble(br.readLine());
     System.out.print("\n");
     loop1:while(opt!='Y')
     {
         System.out.print("Enter option : ");
         q=br.readLine();
         o=q.charAt(0);
         if(o=='=')
         break loop1;
         if(o!='!')
         {
            System.out.print("\nEnter the number : ");
            b=Double.parseDouble(br.readLine());
        }
         switch(o)
         {
             case '+':
             a=a+b;
             break;
             case '-':
             a=a-b;
             break;
             case '/':
             a=a/b;
             break;
             case '*':
             a=a*b;
             break;
             case '!':
             a=Math.sqrt(a);
             break;
             default:
             System.out.println("\nInvalid input");
            }
         System.out.print("\n");
        }
        System.out.println("\nThe result is : "+a+"\n");
        System.out.println("Thank you for using this short program");
    }
}
           
I will be working on a new calculator this time. So keep on a lookout for that one.

Tuesday 1 November 2011

Utilities 19 : How to print in style with Java

Here's a nice program to print anything you want in style. Help yourself to the surprise.

Java Program :

import java.io.*;
import java.util.Random;
class visual
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
   static String s="",s1,a1="";
    static Random r=new Random();
 static void main()throws IOException
 {
     matrix("Welcome to the matrix");
     sleep(1000);
     input();
    }
    static void input()throws IOException
    {
        matrix("Enter any string : ");
        s=br.readLine();
        matrix(s);
    }
    static void matrix(String a)
    {
        int c,i,c1;
        for(c1=0;c1<a.length();c1++)
        {
            for(i=0;i<3;i++)
            {
            c=r.nextInt(123);
            if((c>=48 && c<=57) || (c>=65 && c<=90) || (c>=97 && c<=122))
            {
                System.out.print("\f"+a1+(char)c);
                sleep(70);
            }
            else{
                i=i-1;
               continue;
            }
        }
            a1=a1+a.charAt(c1);
            System.out.print("\f"+a1);
        }
        a1=a1+"\n\n";
 }
 static void sleep(int c)
 {
     try{Thread.sleep(c);}
     catch(Exception e){}
    }
}

Also, I am working on a new school project, to make a Telephone Billing System, and would be posting it soon after my project is over.

ShareThis