code
unknown
plain_text
12 days ago
841 B
6
Indexable
Never
// declaring packages goes before import's package userinput; import java.util.Scanner; class userInput { public int[] getNumber() { Scanner scanner = new Scanner(System.in); System.out.print("Enter the first number : "); int num1 = scanner.nextInt(); System.out.print("Enter the second number : "); int num2 = scanner.nextInt(); return new int[] {num1, num2}; } } class DataProcessor { public int addNumbers(int num1, int num2) { return num1 + num2; } } public class ex1 { public static void main(String[] args) { userInput userinput = new userInput(); DataProcessor dataprocessor = new DataProcessor(); int [] numbers = userinput.getNumber(); int result = dataprocessor.addNumbers(numbers[0],numbers[1]); System.out.print("result: "+result); } }
Leave a Comment