Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners program to implement array of objects
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Pawan Wagh
program to implement array of objects
1 Answer(s)      2 years and 6 months ago
Posted in : Java Beginners


import java.io.*;
import java.util.*;
public class dataa
{
    DataInputStream in=new DataInputStream(System.in);
    int i;
    int a[i]=int acid[5];
    String name1[i]=new String[5];
    float c[i]=new float bal[5];
    String name1;
    int a;
    public void print()
    {
        System.out.println("Enter Your Name:");
        name1=in.readLine();
    }


    public void comparename()
    {
        for(i=1;i<=5;i++)
        {
            if(name1.compareToIgnorecase(name[i]))
            {
                a=0;
            }
            if(a==0)
            {
                System.out.print("Your Account-ID:"+a[i]);
                System.out.println("Your Name:"+name[i]);
                System.out.println("Enter Balance:"+"Rs."+b[i]);
                break;
            }
        }
    }
}

class info
{
    public static void main(String args[])throws IOException
    {
        dataa A=new dataa();
        info();//default constructor
        info(acct_id[i],name[i],bal[i])//parameterized constructor
        {
            for(i=1;i<=5;i++)
            {
                System.out.print("Enter Account-ID:");
                acid[i]=Integer.parseInt(in.readLine());
                System.out.println("Enter Name:");
                name[i]=in.readLine();
                System.out.println("Enter Balance:"+"Rs.");
                bal[i]=Float.parsefloat(in.readLine());
            }
        };
        A.print();
        A.comparename();
    }
}

Advertisement
View Answers

April 9, 2012 at 5:38 PM


import java.io.*;

public class info
{
   static DataInputStream in=new DataInputStream(System.in);
   static  int acid[]=new int[5];
   static String name[]=new String[5];
    static float bal[]=new float[5];
    static String name1;
    static int a;
    public static void print()
    {
        try{
        System.out.print("Enter Your Name:");
        name1=in.readLine();
        }
        catch(Exception E){}
    }


    public static void comparename()
    {
        for(int i=0;i<5;i++)
        {
            if(name1.equalsIgnoreCase(name[i]))
            {
                a=0;
            }
            if(a==0)
            {
                System.out.println("Your Account-ID:"+acid[i]);
                System.out.println("Your Name:"+name[i]);
                System.out.println("Enter Balance:"+"Rs."+bal[i]);
                break;
            }
        }
    }


 public static void main(String args[])throws IOException  {


            for(int i=0;i<5;i++)
            {
                System.out.print("Enter Account-ID:");
                acid[i]=Integer.parseInt(in.readLine());
                System.out.print("Enter Name:");
                name[i]=in.readLine();
                System.out.print("Enter Balance:"+"Rs.");
                bal[i]=Float.parseFloat(in.readLine());
            }

      print();
       comparename();
    }
}


Related Tutorials/Questions & Answers:
Program to implement array of Objects.
Program to implement array of Objects.  Create a class it has.... Initialize an array of objects. Pass a name from the command line & search for the name in the array of objects , if it is existing print the information
program to implement array of objects
program to implement array of objects  import java.io.*; import java.util.*; public class dataa { DataInputStream in=new DataInputStream(System.in); int i; int a[i]=int acid[5]; String name1[i]=new String[5
Advertisements
Implement array of objects
Implement array of objects  import java.io.*; import java.util.*; public class dataa { DataInputStream in=new DataInputStream(System.in); int i; int a[i]=int acid[5]; String name1[i]=new String[5
Sun's JDBC-ODBC driver does not implement the getPrimaryKeys() method for the DatabaseMetaData Objects.
Sun's JDBC-ODBC driver does not implement the getPrimaryKeys() method for the DatabaseMetaData Objects.  Is there a way to find the primary key(s) for an Access Database table? Sun's JDBC-ODBC driver does not implement
JSON array objects retrieval in javascript
JSON array objects retrieval in javascript   I am fetching some data from database and want to show these values in a combo in javascript but combo box is not populating any value, perhaps i am doing something wrong in json
retrieve JSON array objects in javascript
retrieve JSON array objects in javascript  I am getting one value by JSON array, but how can i store multiple values in json array and how can i retieve it by javascript? Any help please auto.jsp <script type="text
array program
array program  write a java program which will take 10 elements as command line arguments and count how many times 3 occurs in array
program of array
program of array  write a program that initializes an array with ten random integers and then prints four lines of output,containing:every element at an even index,every even element,all elements in reverse order,and only
program in array
program in array  print("code sample");write a program that initializes an array with ten random integers and then prints four lines of output...[]=new int[10]; System.out.println("Array of Random Numbers
declare a variable that will store an array of 5 objects
declare a variable that will store an array of 5 objects  Q7. Give a declaration for a variable that will 'store' an array of 5 Card objects... you   Declare Array of 5 objects in the following way: int list[]=new
JavaScript array of objects
JavaScript array of objects   ... that help you in understanding JavaScript array of objects. For this we are using... that is used to instantiate an array object and is initialized with various list
saving form bean with Array of objects (collection) - Struts
saving form bean with Array of objects (collection)  Hi all... thanks..:) I am facing problem to capture my array of objects(Order) in form bean... an array of objects(Order.java) Order.java (java bean)- value object implements
java program based on array
StudentDemo which will have main method. Declare array of Student object with size 10. Initialize all 10 elements of this array with new objects. Write logic which...java program based on array  Create Student class with attributes
one dimensional array program
one dimensional array program  Design and implement a java program that will read a file containing numbers and compute the following statistics: the rannge( low, high), the average and the median(middle number). Notes
how to make a program on array
how to make a program on array  When you make a program on array that the element will move downward and upward and when you input twice 0 then thats the time that it will not move. pls. give me a formula...tnx
java program based on array
java program based on array  write a program to create an array of 10 integers in main.accept values from the user in that array .now again ask the use another nomber and pass the array and the no. entered to function called
array variable in a java program
array variable in a java program  How do i write a program that will prompt the user for a list of 5 prices, that cosist of the sum of all the prices, the average of the prices, and all prices that are higher than the calculated
Creating Array Objects in JavaScript with JSON
Creating Array Objects in JavaScript with JSON... in this tutorial we have provided you the way array of objects are declared...; which contains two array objects "Maths" and "Science"
Two Dimensional array program
to elements of the array such that the last element become the first one and the first become the last.let the program output elements of the first array...Two Dimensional array program  consider a two dimensional array
Reverse integer array program
Reverse integer array program  Been tasked with the following question: Write a method that accepts an integer array and returns a new array with all the elements in reverse order. For example, if the input array is [2, 4, 6, 8
write a program to demonstrate call by value and call by reference.(pass objects as parameters)
write a program to demonstrate call by value and call by reference.(pass objects as parameters)  write a program to demonstrate call by value and call by reference.(pass objects as parameters
Insert an array list of objects with addAll(ArrayList) method
Insert an array list of objects with addAll(ArrayList) method In this section you will learn to insert an array list of objects to another list. Here is an example that provides the usage of the addAll(Arrayist
Two Dimensional Array Program
Two Dimensional Array Program Using Nested for loop...; program . In this session we will teach how to use of a two dimensional array. First of all we will define a class "Matrix". In this program we
java 2 d array program
java 2 d array program  write a program 2-d matrix addition through user's input?  Hi Friend, Try the following code: import java.util.*; class MatrixAddition{ public static void main(String[] args
Three Dimensional Array program
Three Dimensional Array program       This is a very simple Java program. In this program we... the multidimensional array we are going to make a matrix. Now in this program use
Two Dimensional Array Program
will learn how to display arrange form of two dimensional array program... a integer for array declaration Two dimensional array program. We are going... Two Dimensional Array Program    
create and use an array variable in a java program
create and use an array variable in a java program  how do i write a program that will prompt the user for a list of 5 prices, once the user has entered all values , your program should compute and display the following: The sum
Objects
Objects       Objects In this section we are going to illustrate how the real life objects are the key to understand object-oriented technology Objects are the part of our day to day
Array list java program - Java Interview Questions
Array list java program  Create an employee class with an employee id's,name & address. Store some objects of this class in an arraylist. When... and address variables..how we can store objects of that class in arraylist and how
JavaScript array queue
JavaScript array queue       In the JavaScript array we can implement the Queue by using the push... to implement Queue by using the JavaScript array methods as follows: javascript
Two Dimensional Array Program Using Nested For Loop
Two Dimensional Array Program Using Nested For Loop        This is very simple program... dimensional array program. Firstly, we have to define class "TwoDimensional "
Advertisements
 

 

 

DMCA.com