import java.util.Scanner;
public class SwapValues {
public static void main(String[] args) {
public void swapFunction(int a, int b) {
// First, I declare the new Scanner to take the user's input for integers.
Scanner in = new Scanner(
System.in);
System.out.println("Enter a value for Value 1: ");
int V1 = in.nextInt();
System.out.println("Enter a value for Value 2: ");
int V2 = in.nextInt();
// Next, I reiterate what the user entered for their values, allowing them one more chance to see if the values they entered are the values they intended to enter.
System.out.println("Value 1 = " + V1);
System.out.println("Value 2 = " + V2);
// Now, I simply assign new variables for V1 and V2, appropriately named NewV1 and NewV2, and set their values equal to the opposing variable's old value.
int NewV1 = V2;
int NewV2 = V1;
// Lastly, I display to the user what the swapped values are.
System.out.println("The new value for Value 1 is: " + NewV1);
System.out.println("The new value for Value 2 is: " + NewV2);
}
}
}