Server IP : 172.16.15.8 / Your IP : 3.147.28.111 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/zwang/cs202/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// // Name: Adder.java // // Worksheet #2 // import java.util.*; public class Adder { // #a // two instance var. private int a; private int b; // one constructor public Adder(int v1, int v2) { a = v1; b = v2; } public int Addition () { return a + b; } public String toString() { return a + " + " + b + " = " + Addition(); } // #b public static void main(String[] args) { // decl. objects Adder answer; Scanner sc = new Scanner(System.in); // read in the values System.out.print("Input two integers: "); int num1 = sc.nextInt(); int num2 = sc.nextInt(); // store to object answer = new Adder(num1, num2); // output System.out.println(answer); System.out.println("\n\nDone.\n\n"); } }