Categories: Homework on time

Case Western Reserve University Attendance Program to Add Student Grade Exercise I already have attendanc program but I need to add student grade to that p

Case Western Reserve University Attendance Program to Add Student Grade Exercise I already have attendanc program but I need to add student grade to that program import
import
import
import
import
import
import
import
javax.swing.*;
java.awt.*;
java.awt.event.ActionEvent;
java.awt.event.ActionListener;
java.io.BufferedReader;
java.io.FileReader;
java.io.IOException;
java.util.ArrayList;
public class Driver extends JFrame {
public Driver(String title) {
super(title);
ArrayList students = new ArrayList();
read_names(students);
Dimension size = new Dimension(200,200);
setSize(size);
JPanel mainPanel = new JPanel(new FlowLayout());
mainPanel.add(new JLabel(“Attendance System”));
JComboBox studentName = new JComboBox();
for (int i = 0; i < students.size(); i++) { studentName.addItem(students.get(i).getFirstName() + " " + students.get(i).getLastName()); } JComboBox attendance = new JComboBox(); attendance.addItem("P - Present"); attendance.addItem("A - Absent"); attendance.addItem("L - Late"); mainPanel.add(studentName); mainPanel.add(attendance); JButton changeStudents = new JButton("Add Attendance"); changeStudents.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { addAttendance(students, studentName.getSelectedItem().toString(), attendance.getSelectedIndex()); } }); mainPanel.add(changeStudents); JButton showStudents = new JButton("Show Student"); showStudents.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { showStudentsDialog(students, studentName.getSelectedItem().toString()); } }); mainPanel.add(showStudents); add(mainPanel); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } private void read_names(ArrayList students) { try (FileReader reader = new FileReader("students.txt"); BufferedReader br = new BufferedReader(reader)) { // read line by line String line; while ((line = br.readLine()) != null) { Student st = new Student(line.trim().split(";") [0],line.trim().split(";")[1]); students.add(st); } } } catch (IOException e) { System.err.format("IOException: %s%n", e); } private void showStudentsDialog(ArrayList students, String name) { for (int i = 0; i < students.size(); i++) { if ((students.get(i).getFirstName() + " " + students.get(i).getLastName()).equals(name)) { String output = ""; if (students.get(i).limitAbsent()) { output = "Limit Absent -> “;
}
output += ” Name: ” + name;
output += “nPresent: ” + students.get(i).getPresent();
output += “nAbsent: ” + students.get(i).getAbsent();
output += “nLate: ” + students.get(i).getLate();
JOptionPane.showMessageDialog(null, output);
}
}
}
private void addAttendance(ArrayList students, String name, int
attendance) {
for (int i = 0; i < students.size(); i++) { if ((students.get(i).getFirstName() + " " + students.get(i).getLastName()).equals(name)) { if (attendance == 0) { // Present students.get(i).setPresent(); } else if (attendance == 1) { students.get(i).setAbsent(); } else { students.get(i).setLate(); } JOptionPane.showMessageDialog(null, "Student updated!"); } } } } public static void main(String[] args) { Driver d = new Driver("Attendance System"); d.setVisible(true); } public class Student { private private private private private String firstName; String lastName; int present; int absent; int late; public Student(String fn, String ln) { firstName = fn; lastName = ln; absent = 0; present = 0; late = 0; } public void setFirstName(String firstName) { this.firstName = firstName; } public void setLastName(String lastName) { this.lastName = lastName; } public void setPresent() { this.present++; } public void setLate() { this.late++; if (this.late % 2 == 0) { setAbsent(); this.late = 0; } } public void setAbsent() { this.absent++; } public String getFirstName() { return this.firstName; } public String getLastName() { return this.lastName; } public int getPresent() { return this.present; } public int getAbsent() { return this.absent; } public int getLate() { return this.late; } public boolean limitAbsent() { return (this.absent >= 4);
}
}

Purchase answer to see full
attachment

Don't use plagiarized sources. Get Your Custom Essay on
Case Western Reserve University Attendance Program to Add Student Grade Exercise I already have attendanc program but I need to add student grade to that p
Just from $13/Page
Order Essay
superadmin

Share
Published by
superadmin

Recent Posts

Consider the following information, and answer the question below. China and England are internation

Consider the following information, and answer the question below. China and England are international trade…

4 years ago

The CPA is involved in many aspects of accounting and business. Let’s discuss some other tasks, othe

The CPA is involved in many aspects of accounting and business. Let's discuss some other…

4 years ago

For your initial post, share your earliest memory of a laser. Compare and contrast your first percep

For your initial post, share your earliest memory of a laser. Compare and contrast your…

4 years ago

2. The Ajax Co. just decided to save $1,500 a month for the next five years as a safety net for rece

2. The Ajax Co. just decided to save $1,500 a month for the next five…

4 years ago

How to make an insertion sort to sort an array of c strings using the following algorithm: * beg, *

How to make an insertion sort to sort an array of c strings using the…

4 years ago

Assume the following Keynesian income-expenditure two-sector model:

Assume the following Keynesian income-expenditure two-sector model:                                                AD = Cp + Ip                                                Cp = Co…

4 years ago