Question

Java This application will be menu driven. The application should allow: 1. Collect student information and...

Java

This application will be menu driven.

The application should allow:

1. Collect student information and store it in a binary data file. Each student is identified by an unique ID.  
The user should be able to view/edit an existing student. Do not allow the user to edit student ID.

2. Collect Course information and store it in a separate data file. Each course is identified by an unique ID.
The user should be able to view/edit an existing course information.
User is not allowed to edit the key field such as Course ID.

3. Collect Enrollment information.
Here you allow the user to enroll students to courses.
You make sure that the user types valid student id and course ID.
You display the student and course information in the window.
You will have to store enrollment information in a separate binary file.
This file may contain the course, student ID, Year and semester information.

4. Grade Management, such as Add grades, View Grades.
You will allow the user to enter student ID, year, Semester, course ID, and the grade.
The user should be above to view/edit the grades.

You can create a menu driven interface to select the above options.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.io.*;

//package com.farenda.java.io;

import java.io.*;

import java.io.BufferedOutputStream;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.OutputStream;

import java.nio.charset.StandardCharsets;

class Student

{

String studentId;

String name;

String phoneNo;

Student(String id,String name,String phone)

{

this.studentId=id;

this.name=name;

this.phoneNo=phone;

}

public String getId()

{

return studentId;

}

public String getName()

{

return name;

}

public String getPhoneNo()

{

return phoneNo;

}

public void setName(String name)

{

this.name=name;

}

public void setPhoneNumber(String no)

{

this.phoneNo=no;

}

public String toString()

{

return "\n\tStudent Id: "+studentId+"\n\tStudent Name: "+name+"\n\tPhoneNo: "+phoneNo+"\n";

}

private static byte[] getUtf8Bytes(String s) {

// Always specify encoding and not rely on default!

return s.getBytes(StandardCharsets.UTF_8);

}

}

//This is Course file

class Course

{

String courseId;

String courseName;

Course(String cid,String cname)

{

this.courseId=cid;

this.courseName=cname;

}

public String getCourseId()

{

return courseId;

}

public String getCourseName()

{

return courseName;

}

public void setCourseName(String cname)

{

this.courseName=cname;

}

public String toString()

{

return "CourseId: "+courseId+"\tCourseName: "+courseName+"\n";

}

}

//this is Enrollment class. Here you will be find main method also

import java.io.*;

import java.nio.ByteBuffer;

public class Enrollment

{

Student newStudent;

Course newCourse;

String year;

String semester;

float grade;

Enrollment(Student s,Course c,String y,String sem)

{

this.newStudent=s;

this.newCourse=c;

this.year=y;

this.semester=sem;

}

public void setGrade(float gr)

{

this.grade=gr;

}

public float getGrade()

{

return grade;

}

public String toString()

{

return "Student Info: "+newStudent+"\n\tCourseInfo: "+newCourse+"\n\tYear: "+year+

"\n\tSemester"+semester+"\n\tGrade: "+grade+"\n";

}

public void writeStudentFile()throws IOException

{

OutputStream output = null;

try {

byte[] result =newStudent.toString().getBytes();

//result= ()newStudent.toString();

output = new BufferedOutputStream(new FileOutputStream("student_out.dat"));

//OutputStream output=openFile("data.dat");

output.write(result,0,result.length);

//output.write(getUtf8Bytes(studentId+"\t"+name+"\t"+phoneNo+"\n"));

//output.writeBytes(studentId+"\t"+name+"\t"+phoneNo+"\n");

}

finally {

output.close();

}

}

public static byte[] toByteArray(float value) {

byte[] bytes = new byte[4];

ByteBuffer.wrap(bytes).putFloat(value);

return bytes;

}

public void writeEnrollmentFile()throws IOException

{

OutputStream output = null;

try {

byte[] id =newStudent.getId().getBytes();

byte [] cid=newCourse.getCourseId().getBytes();

byte[] ye=year.getBytes();

byte[] se=semester.getBytes();

byte[] bytes = toByteArray(grade);

//result= ()newStudent.toString();

output = new BufferedOutputStream(new FileOutputStream("Enrollment_out.dat"));

//OutputStream output=openFile("data.dat");

output.write(id,0,id.length);

output.write(cid,0,cid.length);

output.write(ye,0,ye.length);

output.write(se,0,se.length);

output.write(bytes,0,bytes.length);

//output.write(getUtf8Bytes(studentId+"\t"+name+"\t"+phoneNo+"\n"));

//output.writeBytes(studentId+"\t"+name+"\t"+phoneNo+"\n");

}

finally {

output.close();

}

}

public void writeCourseFile()throws IOException

{

OutputStream output = null;

try {

byte[] result =newCourse.toString().getBytes();

//result= ()newStudent.toString();

output = new BufferedOutputStream(new FileOutputStream("course_out.dat"));

//OutputStream output=openFile("data.dat");

output.write(result,0,result.length);

//output.write(getUtf8Bytes(studentId+"\t"+name+"\t"+phoneNo+"\n"));

//output.writeBytes(studentId+"\t"+name+"\t"+phoneNo+"\n");

}

finally {

output.close();

}

}

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

{

int opt;

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

System.out.println("\n------ Student Course Enrollment System------\n");

do

{

System.out.println("-----Collect Student Info-----");

System.out.println("Enter Student Id: ");

String id=br.readLine();

System.out.println("Enter Student Name: ");

String name=br.readLine();

System.out.println("Enter Student PhoneNum: ");

String phone=br.readLine();

Student s=new Student(id,name,phone);

System.out.println("\n------Enter Course Info-------\n");

System.out.println("Enter Course Id: ");

String cid=br.readLine();

System.out.println("Enter Course Name: ");

String cn=br.readLine();

Course co=new Course(cid,cn);

System.out.println("Enter the Current Year: ");

String yr=br.readLine();

System.out.println("Enter the Semester slot: ");

String seme=br.readLine();

Enrollment fresh=new Enrollment(s,co,yr,seme);

System.out.println("Enter the Grade points: ");

float gr=Float.parseFloat(br.readLine());

fresh.setGrade(gr);

fresh.writeCourseFile(); //Writing data into course_out.dat file

fresh.writeStudentFile(); //writing data into student_out.dat file

fresh.writeEnrollmentFile(); //writing data into enrollment_out.dat file

System.out.println(fresh);

System.out.println("Do you want to add another Enrollment? Press 1 for Yes\t 2 for No:\t");

opt=Integer.parseInt(br.readLine());

}while(opt!=2);

}

}

Add a comment
Know the answer?
Add Answer to:
Java This application will be menu driven. The application should allow: 1. Collect student information and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The application should be in JAVA and allow: 1. Collect student information and store it in...

    The application should be in JAVA and allow: 1. Collect student information and store it in a binary data file. Each student is identified by an unique ID. The user should be able to view/edit an existing student. Do not allow the user to edit student ID. 2. Collect Course information and store it in a separate data file. Each course is identified by an unique ID. The user should be able to view/edit an existing course information. User is...

  • In JAVA please! Write program for exercises You will write a Graphical User Interface(GUI) application to manage student...

    In JAVA please! Write program for exercises You will write a Graphical User Interface(GUI) application to manage student information system. The application should allow: 1. Collect student information and store it in a binary data file. Each student is identified by an unique ID. The user should be able to view/edit an existing student. Do not allow student to edit ID. 2. Collect Course information and store it in a separate data file. Each course is identified by an unique...

  • Design and code a JAVA program called ‘Grades’. ? Your system should store student’s name, and...

    Design and code a JAVA program called ‘Grades’. ? Your system should store student’s name, and his/her course names with grades. ? Your system should allow the user to input, update, delete, list and search students’ grades. ? Each student has a name (assuming no students share the same name) and some course/grade pairs. If an existing name detected, user can choose to quit or to add new courses to that student. ? Each student has 1 to 5 courses,...

  • In C++ Write a menu driven C++ program to read a file containing information for a list of Students, process the data, t...

    In C++ Write a menu driven C++ program to read a file containing information for a list of Students, process the data, then present a menu to the user, and at the end print a final report shown below. You may(should) use the structures you developed for the previous assignment to make it easier to complete this assignment, but it is not required. Required Menu Operations are: Read Students’ data from a file to update the list (refer to sample...

  • For this assignment we are going to create the beginnings of a simple Grade Book. We...

    For this assignment we are going to create the beginnings of a simple Grade Book. We will revisit this assignment again once we learn some new concepts. For the purposes of this grade book you should first provide a menu with the following options: 1. Add a new course 2. Add a new student 3. Add a student to a course 4. Add grades for a student in a course 5. Print a list of all grades for a student...

  • python anywhere questions. A Class Management System, Part 2 Please also refer to the description provided...

    python anywhere questions. A Class Management System, Part 2 Please also refer to the description provided in Part 1 of the project “A Class management System”. You have had a chance to state your understanding of the requirements for this project, draft a preliminary design, and express it by means of UML diagrams. Now it’s time to implement your design. As stated in the original requirements, there will be three categories of users: 1. Students 2. Instructors 3. Administrators Recall...

  • C++ Implement Random Access Binary Files. Do Not use Arrays instead write the data directly to...

    C++ Implement Random Access Binary Files. Do Not use Arrays instead write the data directly to Random Access Binary File. New program should be modified to display a menu for the user to do the following: 1. Replace Employee and Department classes with Employee and Department Structures. 2. Inside each structure, replace all string variables with array of characters. 3. Make Employee and Department editable. That means, the user should be able to edit a given Employee and Department. 4....

  • C++ Implement Random Access Binary Files. Do Not use Arrays instead write the data directly to...

    C++ Implement Random Access Binary Files. Do Not use Arrays instead write the data directly to Random Access Binary File. New program should be modified to display a menu for the user to do the following: 1. Replace Employee and Department classes with Employee and Department Structures. 2. Inside each structure, replace all string variables with array of characters. 3. Make Employee and Department editable. That means, the user should be able to edit a given Employee and Department. 4....

  • Language: C++ Write a program that will allow the instructor to enter the student's names, student...

    Language: C++ Write a program that will allow the instructor to enter the student's names, student ID, and their scores on the various exams and projects. A class has a number of students during a semester. Those students take 4 quizzes, one midterm, and one final project. All quizzes weights add up to 40% of the overall grade. The midterm exam is 25% while the final project 35%. The program will issue a report. The report will show individual grades...

  • using java Program: Please read the complete prompt before going into coding. Write a program that...

    using java Program: Please read the complete prompt before going into coding. Write a program that handles the gradebook for the instructor. You must use a 2D array when storing the gradebook. The student ID as well as all grades should be of type int. To make the test process easy, generate the grade with random numbers. For this purpose, create a method that asks the user to enter how many students there are in the classroom. Then, in each...

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