Answer to Question #320203 in Java | JSP | JSF for Donny

Question #320203

1. Create an application named Numbers whose main() method holds two integer variables. Assign

values to the variables. Pass both variables to methods named sum () and difference(). Create the

methods sum() and difference(); they compute the sum of and difference between the values of two

arguments, respectively. Each method should perform the appropriate computation and display the

results. Save the application as Numbers.cs


1
Expert's answer
2022-03-29T05:19:07-0400
import java.util.Scanner;

public class Numbers {

    public static void sum(int x, int y){
        System.out.println("sum of two numbers: " + (x+y));
    }

    public static void difference(int x, int y){
        System.out.println("difference of two numbers: " + (x-y));

    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("Enter first number: ");
        int x = in.nextInt();
        System.out.print("Enter second number: ");
        int y = in.nextInt();

        Numbers.sum(x, y);
        Numbers.difference(x, y);
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS