I am very new to JAVA Programming and tried to create a Java program consisting of 2 classes and an interface. The main class is StartingPoint.java, the other class is Calculate.java, and the interface is Equations.java.
So far, I have one equation in the Equation.java interface, which consists of a simple add function. I want the program to prompt the user to insert 2 integers and return the added solution. Any help would be greatly appreciated.
This is my main class called StartingPoint.java
import java.util.Scanner; public class StartingPoint { public static void main (String Hoda[]){ System.out.println("Please enter two values"); Scanner a = new Scanner(System.in); Scanner b = new Scanner(System.in); Calculate calculator = new Calculate(); int answer = calculator.add(in.nextInt(a), nextInt(Scanner b)); System.out.print(answer); } }
Here is my second class: Calculate.java
import java.util.Scanner; public class Calculate implements Equations { @Override public int add(Scanner a, Scanner b) {
And here is my interface called Equations.java
import java.util.Scanner; public interface Equations { int add(Scanner a, Scanner b); }
source share