Advertisement
SECT19N

Two methods homework

Oct 26th, 2023
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | Source Code | 0 0
  1. public class Main {
  2.     public static void main(String[] args) {
  3.         int X = 1, Y = 2, Z = 3;
  4.  
  5.         Add(X, Y);
  6.         Add(X, Y, Z);
  7.     }
  8.  
  9.     public static void Add(int first, int second) {
  10.         int sum = first + second;
  11.         System.out.println("The sum of the two variables is: " + sum);
  12.     }
  13.  
  14.     public static void Add(int first, int second, int third) {
  15.         int sum = first + second + third;
  16.         System.out.println("The sum of the three variables is: " + sum);
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement