Search This Blog

Saturday 19 November 2016

Question1: WRITE A JAVA PROGRAM TO CREATE AN ARRAY OF INTEGER TYPE AND FIND THE BIGGEST AND THE SMALLEST ELENTS IN THE GIVEN ARRAY.



PROGRAM LOGIC: CREATED ARRAYS IN ASCENDING ORDER USING BUBBLE SORT AND THEN FINDING THE NUMBERS  AT THE LOWEST POSITION AND AT BIGGEST POSITION
 



import java.io.*;
class array_bubble_sort
{
   public static void bubble_sort() throws IOException
   {
    int y[]=new int[5];
    int temp;
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    for (int m=0;m<y.length;m++)
    {
      System.out.println("enter"+(m+1)+"value");
      y[m]=Integer.parseInt(br.readLine());
    }
    for(int i=0;i<y.length;i++)
    {
     for(int k=0;k< y.length-1;k++)
     {
        if(y[k]>y[k+1])
        {
          temp=y[k];
          y[k]=y[k+1];
          y[k+1]=temp;
        }
        }
    }
    for(int i=0;i<y.length;i++)
    {
        System.out.print(y[i]+" ");
       
    }
         System.out.println("the smallest no. is"+y[0]);
         System.out.println("the biggest no. is"+y[y.length-1]);
    }
 
}





IF YOU HAVE ANY COMPLIMENTS OR ANY DOUBT EMAIL OR COMMENT BELOW

Saturday 29 October 2016

PROGRAM FOR BUBBLE SORTING IN ASCENDING ORDER

import java.io.*;
class array_bubble_sort
{
   public static void bubble_sort() throws IOException
   {
    int y[]=new int[5];
    int temp;
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    for (int m=0;m<y.length;m++)
    {
      System.out.println("enter"+(m+1)+"value");
      y[m]=Integer.parseInt(br.readLine());
    }
    for(int i=0;i<y.length;i++)
    {
     for(int k=0;k<y.length-1;k++)
     {
        if(y[k]>y[k+1])
        {
          temp=y[k];
          y[k]=y[k+1];
          y[k+1]=y[k];
        }
        }
    }
    for(int i=0;i<y.length;i++)
    {
        System.out.print(y[i]);
    }
}
  
}

Wednesday 19 October 2016

TO FIND PRODUCTS OF DIGITS


public class digit_product
{
    public static void digit_product(int n)
    {
        int p=1,i=1,r;
        while(n>0)
        {
            r=n%10;
            p=p*r;
            n=n/10;
        }
        System.out.println("the product is "+p);
    }
}

TO FIND HIGHEST COMMON FACTOR OF TWO NUMBERS



public class hcf
{
    public static void hcf_lcm(int n,int m)
{
    int hcf,lcm,r,k=1;
    while(n>0)
    {
        r=m%n;
        if(r==0)
        {
           hcf=n;
         k=hcf;
        }   
      
       else
       {  n=m;
          n=r;
   
        }
      
  
   
  lcm=n*m/k;

  System.out.println("the hcf of no."+ k);

 System.out.println("the lcm of no."+ lcm);
}
}
}

PALINDROME NUMBER PROGRAM

PROGRAM FOR PALINDROME NUMBER

import java.io.*;
class palindrome
{
    public static void palindrome()throws IOException
    {
     int r,rev=0;
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      System.out.println("enter the no");
      int  n=Integer.parseInt(br.readLine());
        int no=n;
        while(n>0)
        {
            r=n%10;
            rev=rev*10+r;
            n=n/10;
        }
        if(rev == no)
        {
        System.out.println("the no. is palindrome");
    }
    else
    {
        System.out.println("the no is not a palindrome");
    }
}
   
}

PROGRAM FOR NEONE NUMBER

TO FIND WHETHER THE NUMBER IS NEONE OR NOT

public class neon
{
    public static void mkp(int n)
    {
    int sq;
     int r;
     int sum = 0;
     {
        sq = n*n;
     while (sq >0)
    {
        r = sq % 10;
        sum = sum + r;
        sq = sq / 10;
    }
  {
    if(sum == n)
  
    System.out.println("the number is neon number ");
    else
    System.out.println("number is nt a neon number");

}
}

}

}

Sunday 16 October 2016

FIBONACCI SERIRS

public class fibonacci
{
    public static void rmkp(int n)
  { 
     int a = 0;
     int b = 1;
     int c;
     int i= 3;
     System.out.print(a +" "+ b + " "+ " ");  
     while( i <=n)
     {
       c = a + b;
       System.out.print(c);
       a = b;
       b = c;
       i++ ;
     }

    }
    
 }


TO FIND ARMSTRONG NUMBER

import java.io.*;
class armstrong_number
{
 
      public static void armstrong() throws IOException
    {
        int r,p,sum=0;
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in) );
        System.out.println("please enter the number");
      int  n=Integer.parseInt(br.readLine());  
      int no=n;
      while(n>0)
        {
            r=n%10;
            p=r*r*r;
             sum=sum+p;
            n=n/10;
          
        }
    
        if(sum ==no)
       {
           System.out.println("the no. is armstrong no.");
        }
       else
       {
           System.out.println("the no. is not a armsrong no.");
    }
}
}

FOR PATTERN * ** *** **** *** ** *

*
**
***
****
***
**
*
 OUTPUT ABOVE



PROGRAM BELOW


class pattern_star2
{
   public static void pattern4(int no)
   {
 int n=1;
     for (int i=1;i<=no;i++)
    {
       for(int j=1;j<=i;j++)
       {
       System.out.print('*');
        }
         System.out.println( "");
     }
  for (int i=no;i>=1;i--)
    {
       for(int k=1;k<=i-1;k++)
     {
       System.out.print('*');
        }
         System.out.println( "");
     }
    }
}

Saturday 15 October 2016

pattern program for 1 121 12321 1234321

1
   
121
   
12321
   
1234321
above is out put of the following program
below the program

class pattern_E
{
   public static void pattern(int no)
   {
       int n=1;
    for(int p=1;p<=no;p++)
   
    {
        for (int i=no;i>=1;i--)
       {
           System.out.print(" ");
          
        }
        System.out.println("");
      
      
        for(int m=1;m<=p;m++)
        {
            System.out.print(m);
        }
              for(int y=p-1;y>=1;y--)
        {
            System.out.print(y);
        }
       System.out.println("");
    }
    }
}

JAVA program for rating movie(MOVIEMAGIC)

import java.io.*;
class moviemagic
{
    int year;
    String title;
    float rating;
    moviemagic()
    { year=0;
     title="";
     rating=0.00f;
    }
     void input() throws IOException
   
     {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        System.out.println("enter the movie name");
        title=br.readLine();
        System.out.println("enter the year of release");
        year = Integer.parseInt(br.readLine());
        System.out.println("enter the ratings of the movie");
        rating=Float.parseFloat(br.readLine());

    }
    void calculate ()
    {
        if(rating>=0.0 && rating <=2.0)
        {
            System.out.println("the m,ovie is flop");
          
        }
             else if(rating >=2.1&&rating<=3.4)
          {
             System.out.println("the m,ovie is semi hit");
            }  
            else if(rating >=3.5&&rating<=4.5)
           {     System.out.println("the m,ovie is hit");
           
            }   
            else if(rating >=4.6&& rating <=5.0)
        {  
           
            System.out.println("the m,ovie is blockbusterr");
               
               
               
               
            }
       
        }
        void display()
        {
         System.out.println("movie name\t"+"year\t"+"ratings");
         System.out.println(title+"\t"+year+"\t"+rating);
        }
     public static void main (String []args)  throws IOException
     {
         moviemagic obj= new moviemagic ();
         obj.input();
         obj.calculate();
         obj.display();
        
        }
    }

to find longest word in a sentence

import java.io.*;
class longest_word
{
   public static void longest(  ) throws IOException
   {
     BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
     System.out.println("enter the string ");
    String str=br.readLine();
     str=str.trim();
     str=str+" ";
     int l = str.length();
     String max="",temp=" ";
     int maxl=0,tl=0            ,p=0;
  
     for (int i=0;i<l;i++)
     {
        if(str.charAt(i)==32)
        {
            temp=str.substring(p,i);
            tl=temp.length();
       
            if( tl > maxl )
         
                max=temp;
                maxl=tl;
           
         p=i+1;
    }
      
  
    }
      System.out.println("the longest word is"+max);
     System.out.println("the lenght of the longest word is"+maxl);
 }
}

BOOK FAIR PROGRAM

import java.io.*;
class bookfair
{
    //instance variables
    String bname;
    double p;
    double np;
  bookfair()
  {
      bname="";
      p=0.00f;
      np=0.00f;
 
  }
  void input() throws IOException
  {
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      System.out.println("enter the book name");
      bname=br.readLine();
      System.out.println("enter the price");
      p=Double.parseDouble(br.readLine());
    
  }
   void calculate()
   {
    if(p<=1000)
    {
    np=p-(p*0.2);
}
    else if(p>1000 && p<=3000)
  {
    np=p-(p*0.1);
}
    else
{
    np=p-(p*0.15);
   
    }
}

void display()
{
   System.out.println("book name\t"+"price\t"+"net peice\t");
   System.out.println(bname+"\t"+p+"\t"+np);

}
public static void main(String []args) throws IOException
{
    bookfair obj=new bookfair();
    obj.input();
    obj.calculate();
    obj.display();
}
}

Make a JAVA program for a Toystore. This program suggest the toy based on the inputs users gives like age , gender , etc

 //editor used - IntelliJ IDEA package ToyStore; import javax.swing.*; import java.awt.event.*; import java.util.Scanner; //here you can edi...