227k views
0 votes
Create an application named NumbersDemo whose main() method holds two integer variables. Assign values to the variables. In turn, pass each value to methods named displayTwiceTheNumber(), displayNumberPlusFive(), and displayNumberSquared(). Create each method to perform the task its name implies. Save the application as NumbersDemo.java.

User Thewisegod
by
3.3k points

1 Answer

4 votes

Answer:

public class NumbersDemo

{

public static void displayTwiceTheNumber(int number) {

System.out.println("Twice of the number: "+ number * 2);

}

public static void displayNumberPlusFive(int number) {

System.out.println("Number plus five: "+ (number + 5));

}

public static void displayNumberSquared(int number) {

System.out.println("Square of the number: "+ (number * number));

}

public static void main(String[] args) {

int number1 = 7;

int number2 = 28;

displayTwiceTheNumber(number1);

displayNumberPlusFive(number2);

displayNumberSquared(number1);

}

}

Step-by-step explanation:

Each function is defined as requested. Since they display the results, their return type is void, and they take one parameter - an integer.

In the main;

Numbers are initialized.

Functions are called by typing their name, and giving one integer parameter. You can pass any number you like.

User Colan
by
3.9k points