Sunday, 5 October 2014

java program to accept company name and size of screen and display it for 5 objects




import java.io.*;
import java.lang.*;
class mobile
{
String cname;
float size;
void accept()
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
try
{
System.out.print("\n\n\t\tEnter the Company name = ");
cname=br.readLine();
System.out.print("\n\n\t\tEnter the size of Screen = ");
size=Float.parseFloat(br.readLine());
}
catch(IOException e)
{
// System.out.print("\n\n\t\tI/O Error");
}
}
void display()
{
System.out.print("\n\n\t\t=======================================");
System.out.print("\n\n\t\tThe Company Name is = "+cname);
System.out.print("\n\n\t\t========================================");
System.out.print("\n\n\t\tThe Screen Size is = "+size);
}
public static void main(String args[])throws IOException
{
int i;
mobile m[]=new mobile[5];
for(i=0;i<5;i++) { m[i]=new mobile(); m[i].accept(); } for(i=0;i<5;i++) { m[i].display(); } } } OUTPUT : -



6 comments:

  1. This is very important and imformative blog for Java . very interesting and useful for students
    Java Online Training Hyderabad

    ReplyDelete
  2. Elevate your online presence with powerful dedicated servers Chicago. Experience unmatched performance and reliability for your business needs.

    ReplyDelete
  3. Escape to a luxurious resort in jaipur, where royal elegance meets modern comfort. Enjoy world-class amenities, serene landscapes, and unforgettable experiences.

    ReplyDelete