Simple Program In Java

  • Post author:
  • Post category:Java
  • Post comments:0 Comments
import java.util.Scanner;  
class Mobile
{ 

  
  String name;
  int rate;
  String color;
  String version;
  String search; 
  static int i;
  static  int ntamt;

  public static void main(String args[])

  { 

 Mobile m[]=new Mobile[5]; 
   Scanner sc=new Scanner(System.in);  

for(int i=0;i<=4;i++)
{
  m[i]=new Mobile();
}

for(int i=0;i<=4;i++)
{
   System.out.println("Enter Mobile name");  
   String name=sc.next();

	m[i].name=name;

    System.out.println("Enter color");
  String color=sc.next();
 m[i].color=color;
	
 
   System.out.println("Enter rate");  
  int rate=sc.nextInt();
m[i].rate=rate;

System.out.println("Enter version");  
  String version=sc.next();
m[i].version=version;


System.out.println("--------------------------------------");

}

for(int i=0;i<=4;i++)
{
System.out.println(m[i].name+" /"+m[i].color+"/ "+m[i].rate+"/ "+m[i].version+" ");
}

System.out.println("Enter the mobile name you want to buy");
String search=sc.next();

for(int i=0;i<=4;i++)
{
    if(search.equals(m[i].name))
    System.out.println(m[i].name+" /"+m[i].color+"/ "+m[i].rate+"/ "+m[i].version+" ");
    	     
}
}
} 

Leave a Reply