Question

( Object array + input) Write a Java program to meet the following requirements: 1. Define...

( Object array + input) Write a Java program to meet the following requirements:
1. Define a class called Student which contains:
1.1 data fields:
a. An integer data field contains student id
b. Two String data fields named firstname and lastname
c. A String data field contains student’s email address
1.2 methods:
a. A no-arg constructor that will create a default student object.
b. A constructor that creates a student with the specified student id, firstname, lastname and email_address
c. A print method that prints student’s student id, firstname, lastname and email address.
2. Write a test class(xxxx_ Program5) which includes a main() method that will take the students’
information from the standard input (keyboard), create and store the information the students’
information in an object array, then print the student information from the object array.
2.1 The data format of user input is
 The first entry is the number of students (numeric)
 The fields below repeat for each student (each field is separated with a space or spaces)
o Student ID (numeric)
o Student first name (String)
o Student last name (String)
o Student email (String)

example:
5
001 st1_firstname st1_lastname [email protected]
002 st2_firstname st2_lastname [email protected]
003 st3_firstname st3_lastname [email protected]
004 st4_firstname st4_lastname [email protected]
005 st5_firstname st5_lastname [email protected]
2.2 The main() method will
(1) Read the first line from keyboard, save this number (numberOfStudents) to a variable.
(2) Based on the number of students, declare an Student Object array to hold the student objects, and the
array size is nubmerOfStudents.
(3) Using loop statements to read the rest of information for each student, create student objects and store the
objects in the Object array you created above.
(Hint: You can use Scanner class, Scanner’s nextInt() method will get integer values, and it’s next()
method will get String values.)
(4) Using loop statements to print out all student objects from the object array.
( Note: If you use the example input above, your output will be like below.)
Students’ information:
001 st1_firstname st1_lastname [email protected]
002 st2_firstname st2_lastname [email protected]
003 st3_firstname st3_lastname [email protected]
004 st4_firstname st4_lastname [email protected]
005 st5_firstname st5_lastname [email protected]

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
( Object array + input) Write a Java program to meet the following requirements: 1. Define...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Write this in Java. say i have a file called "file.txt" that looked like this: Dunn...

    Write this in Java. say i have a file called "file.txt" that looked like this: Dunn Sean 31111 Duong Geoffrey 29922 Fazekas Nicholas 31100 Prezioso Stefano 22223 Puvvada Mohana 11224 and i have an object class called Student, with three String fields lastName, firstName, and ID. i want to read in file.txt from another class (preferably using BufferedReader) and store each line in the file as a Student in a Student array (example: first line gets stored as ("Dunn" ,...

  • Input hello, I need help completing my assignment for java,Use the following test data for input...

    Input hello, I need help completing my assignment for java,Use the following test data for input and fill in missing code, and please screenshot output. 1, John Adam, 3, 93, 91, 100, Letter 2, Raymond Woo, 3, 65, 68, 63, Letter 3, Rick Smith, 3, 50, 58, 53, Letter 4, Ray Bartlett, 3, 62, 64, 69, Letter 5, Mary Russell, 3, 93, 90, 98, Letter 6, Andy Wong, 3, 89,88,84, Letter 7, Jay Russell, 3, 71,73,78, Letter 8, Jimmie Wong,...

  • In Java(using BlueJ) Purpose Purpose is to practice using file input and output, and array list...

    In Java(using BlueJ) Purpose Purpose is to practice using file input and output, and array list of objects. Also, this lab specification tells you only what to do, you now have more responsibility to design how to do it. Problem description You are given a text file called 'Students.txt' that contains information on many students. Your program reads the file, creating many Student objects, all of which will be stored into an array list of Student objects, in the Students...

  • In Java: Develop a simple class for a Student. Include class variables; StudentID (int), FirstName, LastName,...

    In Java: Develop a simple class for a Student. Include class variables; StudentID (int), FirstName, LastName, GPA (double), and Major. Extend your class for a Student to include classes for Graduate and Undergraduate. o Include a default constructor, a constructor that accepts the above information, and a method that prints out the contents FOR EACH LEVEL of the object, and a method that prints out the contents of the object. o Write a program that uses an array of Students...

  • Description: This Java program will read in data from a file students.txt that keeps records of...

    Description: This Java program will read in data from a file students.txt that keeps records of some students. Each line in students.txt contains information about one student, including his/her firstname, lastname, gender, major, enrollmentyear and whether he/she is a full-time or part-time student in the following format. FIRSTNAME      LASTNAME        GENDER              MAJORENROLLMENTYEAR FULL/PART The above six fields are separated by a tab key. A user can input a keyword indicating what group of students he is searching for. For example, if...

  • In Java programming language Please write code for the 6 methods below: Assume that Student class...

    In Java programming language Please write code for the 6 methods below: Assume that Student class has name, age, gpa, and major, constructor to initialize all data, method toString() to return string reresentation of student objects, getter methods to get age, major, and gpa, setter method to set age to given input, and method isHonors that returns boolean value true for honors students and false otherwise. 1) Write a method that accepts an array of student objects, and n, the...

  • Write a Java program to read customer details from an input text file corresponding to problem...

    Write a Java program to read customer details from an input text file corresponding to problem under PA07/Q1, Movie Ticketing System The input text file i.e. customers.txt has customer details in the following format: A sample data line is provided below. “John Doe”, 1234, “Movie 1”, 12.99, 1.99, 2.15, 13.99 Customer Name Member ID Movie Name Ticket Cost Total Discount Sales Tax Net Movie Ticket Cost Note: if a customer is non-member, then the corresponding memberID field is empty in...

  • CS 2050 – Programming Project # 1 Due Date: Session 3 (that is, in one week!)....

    CS 2050 – Programming Project # 1 Due Date: Session 3 (that is, in one week!). Can be resubmitted up to two times until Session 6 if your first version is submitted by session 3. In this project, you create two classes for tracking students. One class is the Student class that holds student data; the other is the GradeItem class that holds data about grades that students earned in various courses. Note: the next three projects build on this...

  • Create a class named Module2. You should submit your source code file (Module2.java). The Module2 class...

    Create a class named Module2. You should submit your source code file (Module2.java). The Module2 class should contain the following data fields and methods (note that all data and methods are for objects unless specified as being for the entire class) Data fields: A String object named firstName A String object named middleName A String object name lastName Methods: A Module2 constructor method that accepts no parameters and initializes the data fields from 1) to empty Strings (e.g., firstName =...

  • Create a simple Java class for a Month object with the following requirements:  This program...

    Create a simple Java class for a Month object with the following requirements:  This program will have a header block comment with your name, the course and section, as well as a brief description of what the class does.  All methods will have comments concerning their purpose, their inputs, and their outputs  One integer property: monthNumber (protected to only allow values 1-12). This is a numeric representation of the month (e.g. 1 represents January, 2 represents February,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT