0% found this document useful (0 votes)
49 views5 pages

Calcutor: With OBJECT-ORIENTED Approach - Sir John

This document describes an object-oriented calculator program with four classes: Main, AcceptInput, Addition, and Output. The Main class contains the main method that creates an AcceptInput object to get user input for two numbers. The AcceptInput class gets the input and creates Addition and Output objects, passing the numbers to Addition to calculate the sum, then passing the sum to Output to display the result.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views5 pages

Calcutor: With OBJECT-ORIENTED Approach - Sir John

This document describes an object-oriented calculator program with four classes: Main, AcceptInput, Addition, and Output. The Main class contains the main method that creates an AcceptInput object to get user input for two numbers. The AcceptInput class gets the input and creates Addition and Output objects, passing the numbers to Addition to calculate the sum, then passing the sum to Output to display the result.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 5

Calcutor

With OBJECT-ORIENTED approach


- Sir JOHN
Main Class
public class Calculator {

public static void main(String[] args) {

acceptInput askInput = new acceptInput();


askInput.Input();
}
}
AcceptInput Class
class acceptInput
{
int n1, n2;
int s;
float q;
public void Input()
{
n1=Integer.parseInt(JOptionPane.showInputDialog("Enter 1st number: "));
n2=Integer.parseInt(JOptionPane.showInputDialog("Enter 2nd number: "));

addition sum = new addition();

s=sum.add(n1,n2);

output out = new output();


out.labas(s);
}
}
Add Class
class addition
{
int add(int a, int b)
{
int s;
s=a+b;
return s;
}
}
Output CLass
class output
{
void labas(int a)
{
System.out.println("The sum is " + a);
}
}

You might also like