联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> Java编程Java编程

日期:2018-07-30 03:48


Programming and Logic I

Project 2 - Student Assignment


In this project, you will

-input student data from a file

-create a student object

-write the student object data to standard output.  



Download the input text file studentInput.txt.  This file contains four lines with a student’s data.  The first line is the student’s first and last name, the second line is the student’s id number, the third is the student’s year and the fourth containing the student’s major.  


Create a java file called<yourLastName>Student.java.  This file will contain the Student class.  My program would be ConwayStudent.java and my class name would be ConwayStudent.


In the class Student, code the following methods and data:


Fields (all should be private):

- String name

- int idNumber

- char year

- String major


Methods (all should be public):

- No argument constructor

- Constructor with 4 parameters: name, idNumber, year, major

- Accessors and mutators for fields

- a display method that nicely displays the values in the student object: name, id number, year and major


Modify your RunStudent program from project 1 to read a set of data from an input file and create a Student object.  Instead of asking the user for the student data, the program will open the input file for reading (hard code the name of the input file – studentInput.txt) and read the four lines of data from the file.  Make sure to remove the prompts to the user.  You can use the File and Scanner classes to read from the file and you can assume the file exists.  


Store the inputted values in appropriate variables.  As in the previous project, store the name and major as Strings, the id number as an int, and the year as a char (F/O/J/S where F is for freshman, O is for sophomore, J is for junior, S is for senior).


Use the values obtained from the input file to create a student object.  Finally, use the student object to call the display method.  The only output should be a formatted display of the four values in the student object.  


Upload <yourName>Student.java and <yourName>RunStudent.java


版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp