Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How to modify this code to accept the values of the two integers from a user at the keyboard? import java.util.Scanner; public class NumbersDemo

How to modify this code to accept the values of the two integers from a user at the keyboard?

 

import java.util.Scanner;

public class NumbersDemo

{

public static void main (String args[])

{

Scanner readme = new Scanner(System.in);

int n1;

int n2;

n1 = readme.nextInt();

n2 = readme.nextInt();

displayTwiceTheNumber(n1, n2);

displayNumberPlusFive(n1, n2);

displayNumberSquared(n1, n2);

}

public static void displayTwiceTheNumber(int n1, int n2)

{

int times2;

int times22;

times2 = n1 * 2;

times22 = n2 * 2;

System.out.println("2 times 2 is " + times2 + " and 3 times 2 is " +

times22);

}

public static void displayNumberPlusFive(int n1, int n2)

{

int plusFive;

int plusFive2;

plusFive = n1 + 5;

plusFive2 = n2 + 5;

System.out.println("2 plus 5 is " + plusFive + " and 3 plus 5 is " +

plusFive2);

}

public static void displayNumberSquared(int n1, int n2)

{

int numberSquared;

int numberSquared2;

numberSquared = n1 * n1;

numberSquared2 = n2 * n2;

System.out.println("squared is " + numberSquared + " and 3 squared is " + numberSquared2);

}

}

Step by Step Solution

3.32 Rating (119 Votes )

There are 3 Steps involved in it

Step: 1

To modify the given code to accept the values of the two integers from a user at the keyboard you ... blur-text-image

Get Instant Access with AI-Powered 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

Java Programming

Authors: Joyce Farrell

9th edition

1337397075, 978-1337397070

More Books

Students also viewed these Programming questions

Question

Define upstream and downstream with respect to subscriber lines.

Answered: 1 week ago

Question

What are some of the major uses of T-1 lines?

Answered: 1 week ago