Ajpmicro
Ajpmicro
SAKOLI
Session: - 2024-2025
Submitted by
Roll Enrollment
Sr.no Name No No
Suhani D.
1. Aswale 05 2200910002
ACKNOWLEDGEMENT
This completed micro project work come as a gift to me after all the effort let
us gone in to it has been a beautiful endeavor only because of the valuable
guidance of over guide and well – wisher.
Formally we are proud to express our gratitude and respect to each member.
INDEX
1 |P a g e
INTRODUCTION
Project Overview
The Percentage Calculator application built with Java Swing, helps users
calculate their overall percentage based on marks in Physics, Math, Biology, and
English. It provides a straightforward UI for input and computes results instantly.
Key Features
1. Simple Interface: User-friendly UI for entering marks and calculating the
overall percentage.
3. Error Handling: Validates input to ensure only valid scores are entered.
Technology Used
2 |P a g e
SOURCE CODE
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public FixedMaxMarksPercentageCalculator() {
initializeUI();
}
// Heading label
JLabel headingLabel = new JLabel("Percentage Calculator");
headingLabel.setFont(new Font("Arial", Font.BOLD, 20));
headingLabel.setForeground(new Color(0, 102, 204));
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 2;
gbc.anchor = GridBagConstraints.CENTER;
panel.add(headingLabel, gbc);
gbc.anchor = GridBagConstraints.WEST;
gbc.gridwidth = 1;
3 |P a g e
// Subject labels and text fields
physicsField = new JTextField(10);
mathsField = new JTextField(10);
bioField = new JTextField(10);
englishField = new JTextField(10);
// Result labels
resultLabel = new JLabel("Percentage: --%");
resultLabel.setFont(new Font("Arial", Font.BOLD, 16));
resultLabel.setForeground(new Color(0, 102, 102));
// Calculate button
JButton calculateButton = new JButton("Calculate");
calculateButton.setBackground(new Color(0, 153, 153));
calculateButton.setForeground(Color.WHITE);
calculateButton.setFont(new Font("Arial", Font.BOLD, 13));
calculateButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
calculateResults();
}
});
gbc.gridy = 6;
panel.add(totalLabel, gbc);
4 |P a g e
gbc.gridy = 7;
panel.add(resultLabel, gbc);
private void addField(JPanel panel, GridBagConstraints gbc, int row, String label,
JTextField field) {
gbc.gridx = 0;
gbc.gridy = row;
panel.add(new JLabel(label), gbc);
gbc.gridx = 1;
panel.add(field, gbc);
}
// Display results
totalLabel.setText(String.format("Total Marks: %.2f / 400", totalMarksObtained));
resultLabel.setText(String.format("Percentage: %.2f%%", percentage));
} catch (NumberFormatException e) {
5 |P a g e
JOptionPane.showMessageDialog(null, "Please enter valid numbers for all
subjects.");
}
}
6 |P a g e
OUTPUT
7 |P a g e
REFERENCES
• https://www.ilovepdf.com/pdf_to_word
• https://gemini.google.com/app/e25ca4620ab28eaa
• www.youtube.com
• https://www.javatpoint.com/java-swing
• https://chatgpt.com/c/6707eb4f-3fa0-8001-8fbc-
a128156a99f2
• https://www.w3schools.com
8 |P a g e