Question: Given the integer array yearlyMiles with the size of NUM _ INPUTS, write a for loop to output the integers in the first half of
Given the integer array yearlyMiles with the size of NUMINPUTS, write a for loop to output the integers in the first half of yearlyMiles. Separate the integers with a dash surrounded by spaces
Ex: If the input is then the output is:
import java.util.Scanner;
public class MileData
public static void mainString args
Scanner scnr new ScannerSystemin;
final int NUMINPUTS ;
int yearlyMiles new intNUMINPUTS;
int i;
for i ; i yearlyMiles.length; i
yearlyMilesi scnrnextInt;
for i ; i NUMINPUTS ; i
System.out.printyearlyMilesi;
System.out.println;
Within the for loop, an if statement can be used to output a dash surrounded by spaces after each integer, excluding the last integer output.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
