Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

More Books

Students also viewed these Databases questions