subject

Copy the following code into a new Java file in Eclipse.

import java. util. Scanner;

public class EclipseVsZyBooks {

public static void main(String[] args) {

System. out. println("Enter an integer: ");

int a = readInt();

System. out. println("Enter a second integer: ");

int b = readInt();

if(a == b)

System. out. println(a + " equals " + b);

else if (a < b)

System. out. println(a + " is less than " + b);

else

System. out. println(a + " is more than " + b);

}

public static int readInt() {

Scanner sc = new Scanner(System. in);

return sc. nextInt();

}

}

(2) Run the code in Eclipse.

(3) Try running the code in 1.14 zyBooks built-in programming window, using the same input that you did in (2). You can use this environment to test your code before submitting it to zyBooks.

(4) Try submitting the code. You should see that the 3 tests produce the same error you saw in (3).

(5) The code should run fine in (2), but give you errors in (3) and (4). Refactor the code so that it works in zyBooks just as it does in Eclipse.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 02:00
Consider the following function main: int main() { int alpha[20]; int beta[20]; int matrix[10][4]; . . } a. write the definition of the function inputarray that prompts the user to input 20 numbers and stores the numbers into alpha. b. write the definition of the function doublearray that initializes the elements of beta to two times the corresponding elements in alpha. make sure that you prevent the function from modifying the elements of alpha. c. write the definition of the function copyalphabeta that stores alpha into the first five rows of matrix and beta into the last five rows of matrix. make sure that you prevent the function from modifying the elements of alpha and beta. d. write the definition of the function printarray that prints any onedimensional array of type int. print 15 elements per line. e. write a c11 program that tests the function main and the functions discussed in parts a through d. (add additional functions, such as printing a two-dimensional array, as needed.)
Answers: 3
question
Computers and Technology, 23.06.2019 15:00
What is the total resistance in a circuit that contains three 60 ohm resistors connected in a series? a. 20 ohms b. 120 ohms c. 60 ohms d. 180 ohms
Answers: 2
question
Computers and Technology, 24.06.2019 12:00
Match the function to its purpose. fast worth 50pts.
Answers: 1
question
Computers and Technology, 25.06.2019 06:00
If an image has only 4 colors, how many bits are necessary to represent one pixel’s color?
Answers: 1
You know the right answer?
Copy the following code into a new Java file in Eclipse.

import java. util. Scanner;
Questions
question
English, 18.05.2021 18:50
question
English, 18.05.2021 18:50
question
Mathematics, 18.05.2021 18:50
Questions on the website: 13722360