can somebody help with the following program. im just trying to get started buy
ID: 3784449 • Letter: C
Question
can somebody help with the following program. im just trying to get started buy setting up the student class. can somebody help me creating the student class explained in the instructions with Name, Address, Id number, Courses, and Date. and a bit confused on how to start with going about creating the class the way it describes.
Write a Java program which will store, manipulate, and print student registration information.
As part of the solution, identify the following classes:
Student
Admissions.
The class Student must have the following fields – Name, Address, Id number, Courses, and Date, where:
Name is a user defined class comprising of at minimum first name and last name.
Address is a user defined class comprising of fields - street, city, state, and zip code.
Date is a predefined class in the java.util package
The field Courses is a set of no more than five (5) string values representing the courses being registered for. Course names supplied are assumed to be valid and contains no blank space, for instance COP3337 is valid but not COP 3337.
Id number a string variable that uniquely identifies a student.
The class Student must be capable of adding courses and dropping courses
The class Admissions stores and manipulates the student information (student record). Because the list of students grows dynamically, it is best to use a dynamic data structure such as the ArrayList to store the information. This class should do the following, among other possible activities:
Add student to the list
Remove student from the list, which would first involve locating the record in order to remove it. In order to determine which record to remove you must supply the Id number as the search argument.
You are to provide a test class that coordinates the activities of the classes outlined above, by:
Creating student objects and adding them to the database of the Admissions object
Manipulating student record by:
Adding a course(s)
Dropping a course(s)
Removing a student from the database
Displaying list of currently registered students
Displaying list of all students that were dropped from the course
Display the output in a scrollable pane, and must be formatted as follows:
CURRENTLY ENROLLED
Id number: 123456
Name: Williams, John
Address: 2525 Hartsfield Road
Tallahassee, FL 33319
Date: September 5, 2009
Courses: COP3804, MATH2050, ENG3300
:
:
:
STUDENT WHO WERE DROPPED
Id number: 567890
Name: Roberts, Kay-Anne
Date: September 5, 2009
:
:
Note: Use the class GetData provided to enter the data from the keyboard.
import javax.swing.JOptionPane;
class GetData
{
static double getDouble(String s)
{
return Double.parseDouble(getWord(s));
}
static int getInt(String s)
{
return Integer.parseInt(getWord(s));
}
static String getWord(String s)
{
return JOptionPane.showInputDialog(s);
}
}
The method display shown below shows how to display information in a scrollable pane. Listing 1.8 of text shows how the class GetData and the method display are implemented within a program.
import javax.swing.JOptionPane;
class GetData
{
static double getDouble(String s)
{
return Double.parseDouble(getWord(s));
}
static int getInt(String s)
{
return Integer.parseInt(getWord(s));
}
static String getWord(String s)
{
return JOptionPane.showInputDialog(s);
}
}
Explanation / Answer
import java.io.*;
class Student
{
int rollno;
String name;
int number_of_subjects;
int mark[];
Student(int roll,String stud_name,int noofsub)throws IOException
{
rollno=roll;
name=stud_name;
number_of_subjects= noofsub;
getMarks(noofsub);
}
public void getMarks(int nosub ) throws IOException
{
mark=new int[nosub];
BufferedReader br= new BufferedReader (new InputStreamReader(System.in));
for (int i=0; i<nosub;i++)
{
System.out.println(“Enter “+i+”Subject Marks.:=> “);
mark[i]=Integer.parseInt(br.readLine());
System.out.println(“”);
}
}
public void calculateMarks()
{
double percentage=0;
String grade;
int tmarks=0;
for (int i=0;i<mark.length;i++)
{
tmarks+=mark[i];
}
percentage=tmarks/number_of_subjects;
System.out.println(“Roll Number :=> “+rollno);
System.out.println(“Name Of Student is :=> “+name);
System.out.println(“Number Of Subject :=> “+number_of_subjects);
System.out.println(“Percentage Is :=> “+percentage);
if (percentage>=70)
System.out.println(“Grade Is First Class With Distinction “);
else if(percentage>=60 && percentage<70)
System.out.println(“Grade Is First Class”);
else if(percentage>=50 && percentage<60)
System.out.println(“Grade Is Second Class”);
else if(percentage>=40 && percentage<50)
System.out.println(“Grade Is Pass Class”);
else
System.out.println(“You Are Fail”);
}
}
class StudentDemo
{
public static void main(String args[])throws IOException
{
int rno,no,nostud;
String name;
BufferedReader br= new BufferedReader (new InputStreamReader(System.in));
System.out.println(“Enter How many Students:=> “);
nostud=Integer.parseInt(br.readLine());
Student s[]=new Student[nostud];
for(int i=0;i<nostud;i++)
{
System.out.println(“Enter Roll Number:=> “);
rno=Integer.parseInt(br.readLine());
System.out.println(“Enter Name:=> “);
name=br.readLine();
System.out.println(“Enter No of Subject:=> “);
no=Integer.parseInt(br.readLine());
s[i]=new Student(rno,name,no);
}
for(int i=0;i<nostud;i++)
{
s[i].calculateMarks();
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.