Question
Modify the NumbersDemo class to accept the values of the two integers from a user at the keyboard. Initial Code: public class NumbersDemo2 { //
Modify the NumbersDemo class to accept the values of the two integers from a user at the keyboard.
Initial Code:
public class NumbersDemo2
{
// Modify the code below
public static void main (String args[])
{
int num1 = 4, num2 = 33;
displayTwiceTheNumber(num1);
displayNumberPlusFive(num1);
displayNumberSquared(num1);
displayTwiceTheNumber(num2);
displayNumberPlusFive(num2);
displayNumberSquared(num2);
}
public static void displayTwiceTheNumber(int n)
{
final int FACTOR = 2;
System.out.println(n + " times " + FACTOR + " is " + (n * FACTOR));
}
public static void displayNumberPlusFive(int n)
{
final int FACTOR = 5;
System.out.println(n + " plus " + FACTOR + " is " + (n + FACTOR));
}
public static void displayNumberSquared(int n)
{
System.out.println(n + " squared is " + (n * n));
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started