This is for Java Programming In my code, I'm missing a new line at the end of an array. I'm not sure how to do this. I get the correct output but am missing a newline at the end. Please see attached...


This is for Java Programming



In my code, I'm missing a new line at the end of an array.  I'm not sure how to do this.  I get the correct output but am missing a newline at the end.  Please see attached image for clarity.  My code is below.






import java.util.Scanner;


public class LabProgram {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int[] array=new int[20];


int n;
int a;
int i;


n=scnr.nextInt();


for(i = 0; i < n;="">
array[i]=scnr.nextInt();
a=scnr.nextInt();


for(i = 0; i < n;="">
{
if(array[i]<>
System.out.print(array[i] + " ");
}
}
}





1: Compare output a<br>Output is nearly correct; but whitespace differs. See highlights below. Special character legend<br>Input<br>5 50 60 140 200 75 100<br>Your output<br>50 60 75<br>Expected output<br>50 60 75 e<br>2: Compare output a<br>Output is nearly correct; but whitespace differs. See highlights below. Special character legend<br>Input<br>5 50 60 140 200 75 70<br>Your output<br>50 60<br>Expected output<br>50 60<br>3: Compare output a<br>Output is nearly correct; but whitespace differs. See highlights below. Special character legend<br>Input<br>7 25 32 27 28 27 25 31 30<br>Your output<br>25 27 28 27 25<br>Expected output<br>25 27 28 27 25<br>

Extracted text: 1: Compare output a Output is nearly correct; but whitespace differs. See highlights below. Special character legend Input 5 50 60 140 200 75 100 Your output 50 60 75 Expected output 50 60 75 e 2: Compare output a Output is nearly correct; but whitespace differs. See highlights below. Special character legend Input 5 50 60 140 200 75 70 Your output 50 60 Expected output 50 60 3: Compare output a Output is nearly correct; but whitespace differs. See highlights below. Special character legend Input 7 25 32 27 28 27 25 31 30 Your output 25 27 28 27 25 Expected output 25 27 28 27 25

Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here