0% found this document useful (0 votes)
11 views26 pages

Advancejava PDF

The document is a certificate for a micro-project titled 'Scientific Calculator And Authentication' completed by students of the Computer Engineering department at Government Polytechnic, Achalpur. It outlines the project's aims, methodology, and outcomes, emphasizing secure user access, comprehensive calculations, and a user-friendly interface. The project involves developing a scientific calculator with a login system using Java, integrating GUI frameworks, and database interaction.

Uploaded by

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

Advancejava PDF

The document is a certificate for a micro-project titled 'Scientific Calculator And Authentication' completed by students of the Computer Engineering department at Government Polytechnic, Achalpur. It outlines the project's aims, methodology, and outcomes, emphasizing secure user access, comprehensive calculations, and a user-friendly interface. The project involves developing a scientific calculator with a login system using Java, integrating GUI frameworks, and database interaction.

Uploaded by

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

Department of Computer Engineering

Government Polytechnic, Achalpur


( 2024-25 )

CERTIFICATE

This is to certify that the PowerPoint report entitled

"Scientific Calculator And Authentication"

Has been duly completed by the following students under my guidance, in a

satisfactory manner as partial fulfilment in the diploma course in

Computer Engineering

MSBTE, Mumbai

SUBMITTED BY:

Harsha P. Bende[44] Shruti S. Hend[52] Sapana


G.Wanare[24] Arti S.Nimkarde [34]

Lect. Yadav Sir Prof.A.G.Raut sir


Cource teacher Principal
COURSE: OBJECT ORIENTED PROGRAMMING

Scientific Calculator And Authentication

Submitted by the partial fulfilment of


the Diploma in Computer Engineering

SUBMITTED BY:

Harsha P. Bende(44)
Sruti S.Hend (52)
Sapana G. W.anare(24)
Arti S. Nimk. arde (34)

Guided by:-

Lect. Yadav Sir

Department of Computer Engineering

Government Polytechnic, Achalpur


4.0 ACTION PLAN :-
1
Selection of the topic 01/10/2024 01/10/2024 Harsha P.
[ 1 hrs ] Bende

2
Research about 02/10/2024 02/10/2024 Harsha P.
the [ 2 hrs ] Bende
resources.

3
Collection of 04/10/2024 03/10/2024 Shruti S.
Resources [ 2 hrs ] Hend

4
Creating logic to 06/10/2024 05/10/2024 All members
make the [ 2 hrs ]
program
5
Writing the program 07/10/2024 07/10/2024 Sapana G.
[ 2 hrs ] Wanare

6
Executed program 09/10/2024 08/10/2024
[ 2 hrs ] Arti
S.Nimkarde
7 Harsha P.
Fixed Bugs and errors 12/10/2024 11/10/2024 Bende
[ 2 hrs ]

8
Wrote the Report Arti S.Nimkarde
15/10/2024 13/10/2024
[ 2 Hr ]

9.
Submitted the 21/10/2024 Harsha P.
Micro project Bende Shruti S.
21/10/2024 Hend Sapana G.
[ 1 Hr] Wanare Arti
S.Nimkarde
ANEXURE-|

MICRO-PROJECT PROPOSAL

TITLE OF MICROPROJECT: -

“Scientific Calculator And Authentication”

1.0 AIMS/BENEFITS OF THE MICROPROJECT: -

 Secure User Access: The main aim of this project is to create a secure, user-specific scientific
calculator. By incorporating a login authentication feature, it restricts access and allows only authorized
users to use the application.

 Comprehensive Calculations: This scientific calculator offers a variety of operations, including basic
arithmetic, trigonometric, logarithmic, and power functions, providing users with a complete set of tools
for complex calculations.

 Error Management and User-Friendly Interface: The project ensures that users are provided with real-
time feedback through dialog boxes, with "Login Successful" messages for correct credentials and error
messages for incorrect credentials.

2.0 COURSE OUTCOMES ADDRESSED: -

a) Develop programs using GUI Frameworks (AWT and Swing


b) Handle Events of AWT and Swing Components
c) Develop Programs to Handle Events in Java Programming

3.0 PROPOSED METHODOLOGY: -


 Create a secure login page and a scientific calculator interface with various mathematical operations.
 Compile the Java program, test the calculator and login functionality, and resolve any errors.
 Gather relevant information from reference books and online resources to ensure best practices and accurate
implementation.
 Document the microproject in a structured Word file, ensuring all sections are covered in sequence.
 Add additional details if needed, verify the entire project report, and finalize it for submission.
5.0 RESOURCE REQUIRED :-
Sr.no NAME OF SPECIFICATION OUANTITY
RESOURCES

1. Window 11, 5th GEN, RAM 1


up
OPERATING SYSTEM to 8GB

2. Intellij Idea IDE, , jdk 21, NONE 1


Mysql work bench
3. Websites: -
Websites and books □
https://www.oracle.com/
□ https://chat.openai.co
m/
□ Books : Java 2 fifth
edition
By – Herbert schilft Pub
-McGraw Hill Education,New
Delhi 2015,ISBN :
9781259029936.

Java The Complete Reference


By –
Schildt,H.
Pub -Vikas Pub. New Delhi
2015,ISBN: 9789325969964
Java Progamming
 NAME OF TEAM MEMBERS WITH ROLL NO:

 Harsha P. Bende (44)


 Sruti S. Hend (52)
 Sapana G. Wanare(24)
 Arti S. Nimkarde(34)
ANEXURE-||
MICRO-PROJECT REPORT

TITLE OF THE MICRO-PROJECT

“Scientific Calculator And Authentication”

1.0 RATIONALE: -

Java technology is a versatile and widely used programming language, especially for creating web
applications and desktop solutions. Built on object-oriented principles, Java empowers developers to create
robust, maintainable, and powerful applications. This project leverages Java's core concepts and object-
oriented approach to develop a Scientific Calculator with a seamless user interface and robust backend
functionality. Students working on this project will gain practical experience in GUI development (AWT and
Swing), event handling, and database interaction, aligning with industry demands for skilled Java
developers.

2.0 AIM AND BENEFITS: -

Efficient Calculation Operations: The primary aim of the Scientific Calculator is to perform complex
mathematical operations efficiently. By integrating multiple functionalities into a single application, it
eliminates the need for separate tools and simplifies user tasks.
Enhanced User Experience: With a user-friendly interface designed using AWT and Swing, this
calculator ensures a smooth user experience. Its intuitive design makes it accessible for users with
minimal technical knowledge.
Database Interaction for Enhanced Features: The inclusion of a login system, backed by MySQL,
demonstrates database integration. This ensures secure access and lays the foundation for
implementing advanced features like user preferences and activity logging in the future.

3.0 COURSE OUTCOME ACHIEVED: -

a) Develop programs using GUI Frameworks (AWT and Swing


b) Handle Events of AWT and Swing Components
c) Develop Programs to Handle Events in Java Programming
d) Database Operation Performed
4.0
5.0 ACTUAL METHODOLOGY :-
□ Initially, the Java program for the scientific calculator was designed using Intellij IDEA..
□ The program incorporated mathematical functions and user input validation for accurate calculations.
□ A login system was implemented to demonstrate database interaction.
□ The program was compiled, and any errors encountered during development were debugged
systematically.
□ Output and functionality were tested after resolving errors to ensure the calculator met project
requirements.
□ Information about advanced Java, GUI design using AWT and Swing, and database integration was
collected from various books and reliable online resources.
□ Essential features were added, including a clean user interface, responsive buttons, and error messages
for incorrect inputs.
□ Database connectivity was established to manage user login credentials using MySQL.

5.0 Literature Review:


The Scientific Calculator with Login System integrates advanced mathematical functions like trigonometric
operations, logarithms, and power calculations using Java's Math library for precision. Its user-friendly
interface, designed with AWT and Swing frameworks, mimics traditional calculator layouts for simplicity. To
enhance security, a login feature was implemented using a MySQL database storing user credentials in a
Users table.
Robust error handling ensures smooth operation by validating inputs and managing exceptions effectively.
References such as Java: The Complete Reference and online tutorials on JDBC and GUI development guided
the implementation, ensuring adherence to standard software development practices.
Referred Websites:

• https://www.geeksforgeeks.org/LMS-
• https://www.coursehero.com/file/41666205/Library-Management-SystemPDF
• https://chat.openai.com/ •

Referred Books:

□ Java 2 fifth edition By – herbert schildt


□ Pub -McGraw Hill Education,New Delhi 2015,ISBN : 9781259029936
□ Java The Complete Reference By – Schildt,H.Pub -Vikas Pub. New Delhi, 2015,ISBN: 9789325969964
□ java Programming By - Dr.Rajendra Kawale Pub -Devraj Publications.

□ The java Programming Language , By – Stroustrup,B.


Pub- Sams Publication,New Delhi 2015, ISBN : 9780672323089
6.0 ACTUAL RESOURSE USED:

Sr.no Resources Required QTY

1. Operating system 1
(Window
11)
2. Microsoft office 1

3. Intellij Idea IDE, jdk


21, MySQL
Workbench
4. Printouts As per required
OUTPUT OF THE CODE:

Fig.1

Fig.2
Fig.3

Fig.4
FIG 5
8.0 SKILLS DEVELOPED/LEARNING OUTCOME OF THE MICRO- PROJECT:

➢ Implemented a Java program for the Scientific Calculator with Authentication, reducing
manual calculations and ensuring secure access.
➢ Improved programming skills, particularly in GUI design and database integration.
➢ Enhanced problem-solving techniques through debugging and error handling.
➢ Strengthened leadership qualities by managing project tasks efficiently.
➢ Gained knowledge of new operations and authentication mechanisms.

9.0 APPLICATION OF THE MICROPROJECT:

This microproject demonstrates the creation of a Scientific Calculator with Authentication to


ensure accurate calculations, secure login functionality, and efficient usage for educational and
professional purposes.
SOURCE CODE : LoginPage

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class LoginPage extends JFrame implements ActionListener {

// Components for login


private JTextField userText;
private JPasswordField passwordText;
private JButton loginButton;
private JCheckBox showPasswordCheckBox; // Show password checkbox

// Database credentials
//private final String DB_URL = "jdbc:mysql://localhost:3306/calculator_db"; // Update with your
DB name
//private final String USER = "root"; // Update with your DB username
// private final String PASS = "sandip123"; // Update with your DB password

// Constructor for Login Page


public LoginPage() {
// Frame setup
setTitle("Advanced Login Page");
setSize(600, 500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new BorderLayout());
// Panel for the form
JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout()); // GridBagLayout for better flexibility
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = new Insets(10, 10, 10, 10); // Padding for components

// Title for the login page


JLabel title = new JLabel("Login to Your Account");
title.setFont(new Font("Arial", Font.BOLD, 24));
title.setForeground(Color.BLUE);
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 2;
gbc.anchor = GridBagConstraints.CENTER;
panel.add(title, gbc);

// Username label
JLabel userLabel = new JLabel("Username:");
userLabel.setFont(new Font("Arial", Font.BOLD, 16));
userLabel.setForeground(Color.BLUE);
gbc.gridx = 0;
gbc.gridy = 1;
gbc.gridwidth = 1;
gbc.anchor = GridBagConstraints.LINE_END;
panel.add(userLabel, gbc);

// Username text field


userText = new JTextField(15);
userText.setFont(new Font("Arial", Font.PLAIN, 16));
gbc.gridx = 1;
gbc.gridy = 1;
gbc.anchor = GridBagConstraints.LINE_START;
panel.add(userText, gbc);
// Password label
JLabel passwordLabel = new JLabel("Password:");
passwordLabel.setFont(new Font("Arial", Font.BOLD, 16));
passwordLabel.setForeground(Color.BLUE);
gbc.gridx = 0;
gbc.gridy = 2;
gbc.anchor = GridBagConstraints.LINE_END;
panel.add(passwordLabel, gbc);

// Password field
passwordText = new JPasswordField(15);
passwordText.setFont(new Font("Arial", Font.PLAIN, 16));
gbc.gridx = 1;
gbc.gridy = 2;
gbc.anchor = GridBagConstraints.LINE_START;
panel.add(passwordText, gbc);

// Show password checkbox


showPasswordCheckBox = new JCheckBox("Show Password");
showPasswordCheckBox.setFont(new Font("Arial", Font.PLAIN, 14));
showPasswordCheckBox.setForeground(Color.BLUE);
gbc.gridx = 1;
gbc.gridy = 3;
gbc.anchor = GridBagConstraints.LINE_START;
panel.add(showPasswordCheckBox, gbc);

// Add action listener to checkbox

showPasswordCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (showPasswordCheckBox.isSelected()) {
passwordText.setEchoChar((char) 0); // Show password
} else {
passwordText.setEchoChar('●'); // Hide password
}
}
});

// Login button
loginButton = new JButton("Login");
loginButton.setFont(new Font("Arial", Font.BOLD, 16));
loginButton.setBackground(new Color(41, 128, 185)); // Button background color
loginButton.setForeground(Color.WHITE);
loginButton.addActionListener(this);
gbc.gridx = 0;
gbc.gridy = 4;
gbc.gridwidth = 2;
gbc.anchor = GridBagConstraints.CENTER;
panel.add(loginButton, gbc);

// Adding the panel to the frame


add(panel, BorderLayout.CENTER);
setLocationRelativeTo(null); // Center the frame
setVisible(true);
}

// Action event handling for login button


@Override
public void actionPerformed(ActionEvent e) {
String name = userText.getText();
String password = new String(passwordText.getPassword());

// Database connection and validation


/*
try {
Connection connection = DriverManager.getConnection(DB_URL, USER, PASS);
String sql = "SELECT * FROM users WHERE name = ? AND password = ?"; // Update table
name and field names as necessary
PreparedStatement preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, name);
preparedStatement.setString(2, password);
ResultSet resultSet = preparedStatement.executeQuery();

if (resultSet.next()) {
JOptionPane.showMessageDialog(null,"Login SuccessFully");
// Successful login
dispose(); // Close the login window
new ScientificCalculator(); // Open the scientific calculator window
} else {
JOptionPane.showMessageDialog(this, "Invalid username or password!");
}

// Closing resources
resultSet.close();
preparedStatement.close();
connection.close();
} catch (Exception ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(this, "Database connection error: " + ex.getMessage());
}
*/

if("Calculator-Project".equals(name) && "Calcy_Pro123".equals(password)){

JOptionPane.showMessageDialog(null,"Login SuccessFully");
// Successful login
dispose(); // Close the login window
new ScientificCalculator(); // Open the scientific calculator window
} else{
JOptionPane.showMessageDialog(this, "Invalid username or password!");
}
}

// Main method to run the login page


public static void main(String[] args) {
new LoginPage();
}
}

SOURCE CODE : ScientificCalculator

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class ScientificCalculator extends JFrame implements ActionListener {


// Creating a frame
private JFrame frame;

// Creating a text area


private JTextArea textArea;

// Store operator and operands


private String operator;
private double num1, num2, result;

// Constructor
public ScientificCalculator() {
// Creating a frame
frame = new JFrame("Scientific Calculator - Create By Harshu");
textArea = new JTextArea();

// Setting the text area


textArea.setEditable(false);
textArea.setFont(new Font("Arial", Font.PLAIN, 25));
textArea.setLineWrap(true); // Line wrap for better view
textArea.setRows(3); // Increase rows for larger area

// Create a panel for text area with margin


JPanel textPanel = new JPanel();
textPanel.setLayout(new BorderLayout());
textPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 10, 20)); // Margin: top, left,
bottom, right
textPanel.add(new JScrollPane(textArea), BorderLayout.CENTER); // Add scroll pane for text
area

// Setting the layout


frame.setLayout(new BorderLayout());
frame.add(textPanel, BorderLayout.NORTH); // Add text panel to the top

// Creating buttons
JPanel panel = new JPanel();
panel.setLayout(new GridLayout(8, 4, 10, 10)); // Increased rows for additional buttons
addButtons(panel);

// Create a panel for buttons with margin


JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new BorderLayout());
buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 20, 20, 20)); // Margin: top, left,
bottom, right
buttonPanel.add(panel, BorderLayout.CENTER);

// Adding button panel to frame


frame.add(buttonPanel, BorderLayout.CENTER);

// Frame properties
frame.setSize(500, 800); // Increased frame size
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null); // Center the frame
frame.setVisible(true);
}

// Method to add buttons to the panel


private void addButtons(JPanel panel) {
String[] buttons = {
"7", "8", "9", "/",
"4", "5", "6", "*",
"1", "2", "3", "-",
"0", ".", "=", "+",
"sin", "cos", "tan", "sqrt",
"log", "exp", "pow", "clear",
"%", "!", "arcsin", "arccos",
"arctan", "1/x", "n^x", "x^2"
};

for (String text : buttons) {


JButton button = new JButton(text);
button.setFont(new Font("Arial", Font.PLAIN, 20)); // Adjusted font size for better visibility
button.setPreferredSize(new Dimension(80, 50)); // Adjusted button size
button.addActionListener(this);
panel.add(button);
}
}

// Method to handle button actions


@Override
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();

// Handling number and operators


if (command.charAt(0) >= '0' && command.charAt(0) <= '9' || command.equals(".")) {
textArea.append(command); // Append text to the area
} else if (command.equals("=")) {
try {
num2 = Double.parseDouble(textArea.getText()); // Handle invalid input here
switch (operator) {
case "+":
result = num1 + num2;
break;
case "-":
result = num1 - num2;
break;
case "*":
result = num1 * num2;
break;
case "/":
if (num2 == 0) {
JOptionPane.showMessageDialog(null, "Invalid activity: Division by zero is not
allowed!");
return;
}
result = num1 / num2;
break;
case "sin":
result = Math.sin(Math.toRadians(num2));
break;
case "cos":
result = Math.cos(Math.toRadians(num2));
break;
case "tan":
result = Math.tan(Math.toRadians(num2));
break;
case "sqrt":
if (num2 < 0) {
JOptionPane.showMessageDialog(null, "Invalid activity: Square root of a negative
number is not allowed!");
return;
}
result = Math.sqrt(num2);
break;
case "log":
if (num2 <= 0) {
JOptionPane.showMessageDialog(null, "Invalid activity: Logarithm of zero or
negative number is not allowed!");
return;
}
result = Math.log(num2);
break;
case "exp":
result = Math.exp(num2);
break;
case "pow":
result = Math.pow(num1, num2);
break;
case "%":
result = num1 * (num2 / 100); // Percentage
break;
case "!":
result = factorial(num1); // Factorial
break;
case "arcsin":
if (num2 < -1 || num2 > 1) {
JOptionPane.showMessageDialog(null, "Invalid activity: arcsin is not defined for this
input!");
return;
}
result = Math.toDegrees(Math.asin(num2)); // Inverse sine
break;
case "arccos":
if (num2 < -1 || num2 > 1) {
JOptionPane.showMessageDialog(null, "Invalid activity: arccos is not defined for
this input!");
return;
}
result = Math.toDegrees(Math.acos(num2)); // Inverse cosine
break;
case "arctan":
result = Math.toDegrees(Math.atan(num2)); // Inverse tangent
break;
case "1/x":
if (num2 == 0) {
JOptionPane.showMessageDialog(null, "Invalid activity: Division by zero is not
allowed!");
return;
}
result = 1 / num2; // Reciprocal
break;
case "n^x":
result = Math.pow(num1, num2); // n^x
break;
case "x^2":
result = Math.pow(num2, 2); // Square
break;
}
textArea.setText(String.valueOf(result));
} catch (NumberFormatException ex) {
JOptionPane.showMessageDialog(null, "Invalid activity: Please enter valid numbers!");
}
} else if (command.equals("clear")) {
textArea.setText(""); // Clear the text area
} else {
try {
if (!command.equals("sqrt") && !command.equals("1/x")) {
num1 = Double.parseDouble(textArea.getText());
operator = command;
textArea.setText("");
} else {
operator = command;
num2 = Double.parseDouble(textArea.getText());
result = Math.sqrt(num2);
textArea.setText(String.valueOf(result));
}
} catch (NumberFormatException ex) {
JOptionPane.showMessageDialog(null, "Invalid activity: Please enter valid numbers!");
}
}
}
// Method to calculate factorial
private double factorial(double num) {
if (num < 0) return Double.NaN; // Factorial not defined for negative numbers
double fact = 1;
for (int i = 1; i <= num; i++) {
fact *= i;
}
return fact;
}

You might also like