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.
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)
Available Formats
Download as PPT, PDF, TXT or read online from Scribd
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)
Available Formats
Download as PPT, PDF, TXT or read online from Scribd
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); } }