Given the integer array yearlyPrices with the size of NUM_IN, write a for loop to output...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Answer rating: 100% (QA)
import javautilScanner public class Main public static void mainString args Scanner scnr new Scanner... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
A researcher wanted to find out if there was difference between older movie goers and younger movie goers with respect to their estimates of a successful actors income. The researcher first...
-
USCo, a U.S. corporation, receives $700,000 of foreign-source passive income on which foreign taxes of $70,000 are withheld. Its worldwide taxable income is $1,500,000, and its U.S. tax liability...
-
The diagonals of a quadrilateral ABCD intersect each other at the point O such that AO/BO=CO/DO. Show that ABCD is a trapezium.
-
1.What is the difference between Router and firewall 2.What is Packet filtering router 3.What is Stateful inspection firewall 4.What is Circuit level firewall 5.What is Application level firewall...
-
Corporate Ethics is it ethical for large firms to unilaterally lengthen their payables periods, particularly when dealing with smaller suppliers?
-
Blackwell Automotive' s balance sheet at the end of its most recent fiscal year shows the following information: Blackwell Automotive Balance Sheet as of March 31, 2013 In addition, it was reported...
-
One TOR is equivalent to: (a) \(1 \mathrm{KW}\) (b) \(2.5 \mathrm{KW}\) (c) \(3.5 \mathrm{KW}\) (d) \(5 \mathrm{KW}\)
-
Madsen Company had five convertible securities outstanding during all of 2007. It paid the appropriate interest (and amortized any related premium or discount using the straight-line method) and...
-
Find the derivative of the function f(x) = {3x^2 + 2x - 5}/{x^2 +1}
-
A committee in charge of promoting a Ladies Professional Golf Association tournament is trying to determine how best to advertise the event during the two weeks prior to the tournament. The committee...
-
Majid is an expert supervisor in a garment knitting factory having an experience of 20 years. He is supervising a knitting line at the moment having 5 machines. The knitting line is experiencing a...
-
: how long will you search for a $50 bill that you lost in your bedroom ,if the value of your time is $ 5 per hour?suppose that you know with certainity that it is lost in your bedroom,that the value...
-
Your annual living expenses are $25,000. Assuming that your spending habits dont change over the next 20 years, and the inflation rate would be 4% per year for that 20 year period, what will be your...
-
You are tasked with estimating the cost of capital for a firm. The risk - free rate is 4 . 7 % , the expected rate of return on the market is 1 0 . 7 % . Now, another similar company ( similar...
-
Kai Corp. has $300 million of common equity, with 6 million shares of common stock outstanding. If Kai's Market Value Added (MVA) is $162 million, what is their stock price?
-
Project L costs $65,000, its expected cash inflows are $12,000 per year for 9 years, assuming the WACC is 5%; 10%; 15%, What are the projects IRRs at each of these WACCs?
-
The human resource manager of a company that assembles and exports computer microchips wants to know if there is a link between the number of hours spent by assembly workers in training and their...
-
What are the two components of a company's income tax provision? What does each component represent about a company's income tax provision?
-
Write a program that creates Pet objects from data read from the keyboard. Store these objects into an instance of ArrayList. Then sort the Pet objects into alphabetic order by pet name, and finally...
-
Write a single Java statement that will display the words one, two, and three, each on its own line.
-
Write a static method remove(int v,int[] in) that will return a new array of the integers in the given array, but with the value v removed. For example, if v is 3 and in contains 0, 1, 3, 2, 3, 0, 3,...
-
This chapter reports findings from a recent study by Nellie Mae. To learn more about Nellie Mae and other research findings, visit www.nelliemae.com.
-
Are the initial rates lower on a fixed-rate loan or a variable-rate loan? Why?
-
Visit the Consumer Financial Protection Bureau Web site (www.consumerfinance.gov). Based on the public information available, describe what role the bureau plays in providing consumer education,...
Study smarter with the SolutionInn App