Question: Given the integer array yearlyPrices with the size of NUM_IN, write a for loop to output the integers in the first half of yearlyPric
Given the integer array yearlyPrices with the size of NUM_IN, write a for loop to output the integers in the first half of yearlyPric Separate the integers with a vertical bar surrounded by spaces ("1"). Ex: If the input is 95 81 99 69 32 46 106 43 94 30, then the output is: 95 | 81 | 99 | 69 | 32 4 6 9 10 12 13 14 15 16. 17 18. 19 20 } Check public static void main (String[] args) { Scanner scnr = new Scanner (System.in); final int NUM IN = 10; int[] yearlyPrices = new int [NUM_IN]; int i; } for (i = 0; i < yearlyPrices.length; ++i) { yearlyPrices[i] = scnr.nextInt (); } for (i = 0; i < yearlyPrices.length/2; i++) { System.out.print(yearlyPrices[i] + " "); } System.out.println(); 1 Next level X 1: Compare output A for loop is used to output all integers in the first half of array yearly Prices in order. Within the for loop, an if statement can be used to output a vertical bar surrounded by spaces (1) after each integer, excluding the last integer output. Not all tests passed. Output differs. See highlights below. Special character legend Input 95 81 99 69 32 46 106 43 94 30 Your output 95 | 81 | 99 | 69 | 32 | Expected output 95 81 | 99 | 69 | 32 X 2: Compare output 2 Output differs. See highlights below. Special character legend 3
Step by Step Solution
3.39 Rating (149 Votes )
There are 3 Steps involved in it
import javautilScanner public class Main public static void mainString args Scanner scnr new Scanner... View full answer
Get step-by-step solutions from verified subject matter experts
