subject

ZyLab training: Interleaved input / output (Java) Auto-graded programming assignments have numerous advantages, but have some challenges too. Students commonly struggle with realizing that example input / output provided in an assignment's specification interleaves input and output, but the program should only output the output parts. If a program should double its input, an instructor might provide this example:
Enter x:
5
x doubled is: 25
Students often incorrectly create a program that outputs the 5. Instead, the program should only output the output parts:
Enter x:
x doubled is: 25
The instructor's example is showing both the output of the program, AND the user's input to that program, assuming the program is developed in an environment where a user is interacting with a program. But the program itself doesn't output the 5 (or the newline following the 5, which occurs when the user types 5 and presses enter).
Also, if the instructor configured the test cases to observe whitespace, then according to the above example, the program should output a newline after Enter x: (and possibly after the 25, if the instructor's test case expects that).
The program below incorrectly echoes the user's input to the output.
Try submitting it for grading (click "Submit mode", then "Submit for grading"). Notice that the test cases fail. The first test case's highlighting indicates that output 3 and newline were not expected. In the second test case, the -5 and newline were not expected.
Remove the code that echoes the user's input back to the output, and submit again. Now the test cases should all pass.
import java. util. Scanner;
public class DoubleNum {
public static void main(String[] args) {
Scanner scnr = new Scanner(System. in);
int x;
System. out. println("Enter x: ");
x = scnr. nextInt();
System. out. println(x); // Student mistakenly is echo'ing the input to output to match example
System. out. println("x doubled is: " + (2 * x));
}
}

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 20:00, jayjay5246
What is the term for water wave that is created by an underwater earthquake
Answers: 1
image
Computers and Technology, 23.06.2019 09:30, ranmmm
The place where the extended axis of the earth would touch the celestial sphere is called the celestial
Answers: 1
image
Computers and Technology, 24.06.2019 20:30, glstephens04
How is energy expended in active transport
Answers: 1
image
Computers and Technology, 25.06.2019 08:50, adriandehoyos1p3hpwc
98 points asap you have been asked to create a program for an online store that sells their items in bundles of five. select the appropriate code that would display how many bundles are available for sale. a. print(5 // totalitems) b. print(totalitems // 5) c. print(totalitems(5) ) d. print(5(totalitems) )
Answers: 2
You know the right answer?
ZyLab training: Interleaved input / output (Java) Auto-graded programming assignments have numerous...

Questions in other subjects:

Konu
Mathematics, 03.12.2020 19:10
Konu
English, 03.12.2020 19:10
Konu
World Languages, 03.12.2020 19:10