0% found this document useful (0 votes)
19 views

Java PBL Project

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Java PBL Project

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

IT DEPT CMREC

PROJECT
ON
CGPA CALCULATOR

Submitted to CMREC(UGC Autonomus)


In Partial Full filment of the requirements for the Award of Degree of

BACHELOR OF TECHNOLOGY
IN
INFORMATION TECHNOLOGY
Submitted By

I.Harshenniee 238R1A12F4
G.SAI TEJA REDDY 238R1A12F3
J. BHARATH REDDY 238R1A12F5
J.SUNNY REDDY 238R1A12F6

Under the guidence of

Mrs.G.SWETHA

Assistant Professor

Internal Guide Head of Department


Mrs.G.SWETHA Dr. MADHAVI PINGILI
Assistant Professor Assoc Professor & HOD
Department of IT Department of IT

1
IT DEPT CMREC

CERTIFICATE

This is certify that the OOPS THROUGH JAVA LABORATORY PROJECT


entitled as “CGPA CALCULATOR” is a bonafide record of project work done by

I.Harshenniee 238R1A12F4
G.SAI TEJA REDDY 238R1A12F3
J. BHARATH REDDY 238R1A12F5
J.SUNNY REDDY 238R1A12F6

Under the super vision and guidance of Mrs.G.SWETHA, submitted to CMR


ENGINEERING COLLEGE , in partial fulfillment for the award of the Degree of
Bachelor of Technology in INFORMATION TECHNOLOGY

Mrs.G.SWETHA

2
IT DEPT CMREC

TABLE OF CONTENTS:

1) ABSTRACT 4

2) INTRODUCTION 5

3) CODE 6 - 11

4) IMPLEMENTATION 12

5) CONCLUSION 13

3
JAVA LAB PROJECT

ABSTRACT

The Cumulative Grade Point Average (CGPA) serves as a standardized metric for
evaluating a student's overall academic performance. This abstract provides an
insight into the methodology of CGPA calculation, which involves assigning grade
points to individual course grades, considering credit hours, and deriving a
cumulative measure. The significance of CGPA extends beyond a mere numerical
representation, as it enables easy comparisons between students, departments, and
institutions, serves as a criterion for eligibility in academic and professional
opportunities, and fosters a culture of continuous improvement among students. In
conclusion, CGPA is a pivotal tool in educational assessment, offering a holistic view
of a student's scholastic achievements. Its widespread use underscores its importance
in academic and professional spheres, contributing to transparency, fairness, and the
encouragement of academic excellence.

4
IT DEPT CMREC

INTRODUCTION
The process of Calculating Cumulative Grade Point Average (CGPA) is a
fundamental aspect of academic assessment that provides a comprehensive
representation of a student's overall performance throughout their academic journey.
CGPA serves as a standardized measure, condensing the diverse range of individual
course grades into a single numerical value. This method of evaluation involves the
conversion of letter grades into corresponding grade points, considering credit hours,
and ultimately deriving an average that encapsulates a student's academic
achievements across various subjects. As a widely adopted metric in educational
institutions globally, CGPA not only simplifies the evaluation process but also plays
a crucial role in facilitating comparisons, determining eligibility for academic and
professional opportunities, and fostering a culture of continuous improvement among
students. Understanding the intricacies of CGPA calculation is essential for both
students and educators, as it forms the basis for academic recognition and provides
valuable insights into a student's scholastic capabilities.The next step in the CGPA
calculation considers the credit hours associated with each course. Credit hours
reflect the academic workload and the time commitment required for a particular
course. Multiplying the grade points assigned to each course by the respective credit
hours yields the grade points earned for that course. The cumulative grade points are
then obtained by summing up the grade points earned across all courses.

5
IT DEPT CMREC

CODE:

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;

public class StudentCGPACalculator extends JFrame {


private JTextField subjectNameField, marksField, creditsField;
private JTextArea subjectsArea, resultArea;
private List<Subject> subjects;

public StudentCGPACalculator() {
subjects = new ArrayList<>();

setTitle("Student Percentage and CGPA Calculator");


setSize(500, 600);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLayout(new BorderLayout(10, 10));

// Input Panel
JPanel inputPanel = new JPanel(new GridLayout(4, 2, 5, 5));
inputPanel.setBorder(BorderFactory.createTitledBorder("Add Subject"));

inputPanel.add(new JLabel("Subject Name:"));


subjectNameField = new JTextField();
inputPanel.add(subjectNameField);

inputPanel.add(new JLabel("Marks:"));
marksField = new JTextField();
inputPanel.add(marksField);

inputPanel.add(new JLabel("Credits:"));
creditsField = new JTextField();
6
IT DEPT CMREC

inputPanel.add(creditsField);

JButton addButton = new JButton("Add Subject");


addButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
addSubject();
}
});
inputPanel.add(addButton);

// Subjects Area
subjectsArea = new JTextArea(10, 40);
subjectsArea.setEditable(false);
JScrollPane subjectsScrollPane = new JScrollPane(subjectsArea);
subjectsScrollPane.setBorder(BorderFactory.createTitledBorder("Added
Subjects"));

// Result Area
resultArea = new JTextArea(5, 40);
resultArea.setEditable(false);
JScrollPane resultScrollPane = new JScrollPane(resultArea);
resultScrollPane.setBorder(BorderFactory.createTitledBorder("Results"));

// Calculate Button
JButton calculateButton = new JButton("Calculate Results");
calculateButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
calculateResults();
}
});

// Main Panel
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));

7
IT DEPT CMREC

mainPanel.add(inputPanel);
mainPanel.add(Box.createRigidArea(new Dimension(0, 10)));
mainPanel.add(subjectsScrollPane);
mainPanel.add(Box.createRigidArea(new Dimension(0, 10)));
mainPanel.add(calculateButton);
mainPanel.add(Box.createRigidArea(new Dimension(0, 10)));
mainPanel.add(resultScrollPane);

add(mainPanel, BorderLayout.CENTER);
}

private void addSubject() {


try {
String name = subjectNameField.getText().trim();
double marks = Double.parseDouble(marksField.getText());
int credits = Integer.parseInt(creditsField.getText());

// Validate input data


if (name.isEmpty()) {
JOptionPane.showMessageDialog(this, "Subject name cannot be empty.",
"Input Error", JOptionPane.ERROR_MESSAGE);
return;
}
if (marks < 0 || marks > 100) {
JOptionPane.showMessageDialog(this, "Marks should be between 0 and
100.", "Input Error", JOptionPane.ERROR_MESSAGE);
return;
}
if (credits <= 0) {
JOptionPane.showMessageDialog(this, "Credits should be a positive
number.", "Input Error", JOptionPane.ERROR_MESSAGE);
return;
}

Subject subject = new Subject(name, marks, credits);


subjects.add(subject);

8
IT DEPT CMREC

updateSubjectsArea();
clearInputFields();
} catch (NumberFormatException ex) {
JOptionPane.showMessageDialog(this, "Please enter valid numbers for marks
and credits.", "Input Error", JOptionPane.ERROR_MESSAGE);
}
}

private void updateSubjectsArea() {


StringBuilder sb = new StringBuilder();
for (Subject subject : subjects) {
sb.append(subject.toString()).append("\n");
}
subjectsArea.setText(sb.toString());
}

private void clearInputFields() {


subjectNameField.setText("");
marksField.setText("");
creditsField.setText("");
}

private void calculateResults() {


if (subjects.isEmpty()) {
JOptionPane.showMessageDialog(this, "Please add at least one subject.", "No
Subjects", JOptionPane.WARNING_MESSAGE);
return;
}

double weightedMarksSum = 0;
int totalCredits = 0;

// Calculate the sum of weighted marks and total credits


for (Subject subject : subjects) {
weightedMarksSum += subject.getMarks() * subject.getCredits();
totalCredits += subject.getCredits();
9
IT DEPT CMREC

// Calculate the percentage and CGPA based on total weighted marks and total
credits
double percentage = weightedMarksSum / totalCredits;
double cgpa = percentage / 9.5; // Assuming CGPA is calculated by dividing the
percentage by 9.5

// Format and display the result


String result = String.format("Total Weighted Marks: %.2f\n",
weightedMarksSum) +
String.format("Percentage: %.2f%%\n", percentage) +
String.format("CGPA: %.2f", cgpa);

resultArea.setText(result);
}

private static class Subject {


private String name;
private double marks;
private int credits;

public Subject(String name, double marks, int credits) {


this.name = name;
this.marks = marks;
this.credits = credits;
}

public double getMarks() {


return marks;
}

public int getCredits() {


return credits;
}

10
IT DEPT CMREC

@Override
public String toString() {
return String.format("%s - Marks: %.2f, Credits: %d", name, marks, credits);
}
}

public static void main(String[] args) {


SwingUtilities.invokeLater(() -> new
StudentCGPACalculator().setVisible(true));
}
}

11
IT DEPT CMREC

IMPLEMENTATION

12
IT DEPT CMREC

CONCLUSION

In conclusion, the process of calculating Cumulative Grade Point Average (CGPA) is


a pivotal element in the realm of academic evaluation, serving as a comprehensive
metric that encapsulates a student's overall scholastic achievements. The architecture
supporting CGPA calculations involves an intricate interplay of components, ranging
from user interfaces for data input and retrieval to the calculation engine responsible
for transforming individual grades into a meaningful average. The significance of
CGPA extends beyond its numerical representation, playing a crucial role in
facilitating fair comparisons, determining eligibility for academic and professional
opportunities, and fostering a culture of continuous improvement among students.

13

You might also like