Question: 5 . 4 . 2 : Iterating through arrays. 5 6 9 3 3 8 . 4 5 5 0 4 0 2 . qx

5.4.2: Iterating through arrays.
569338.4550402.qx3zqy7
Jump to level 1
Given the integer array hourlySalaries with the size of ARR_VALS, write a for loop to output the integers in the first half of hourlySalaries. Separate the integers with an asterisk surrounded by spaces ("*").
Ex: If the input is 89119477661453081, then the output is:
89*119*47*76
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import java.util.Scanner;
public class SalaryRange {
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
final int ARR_VALS =8;
int[] hourlySalaries = new int[ARR_VALS];
int i;
for (i =0; i < hourlySalaries.length; ++i){
hourlySalaries[i]= scnr.nextInt();
}
for (i = hourlyTemps.length -1; i >=0; --i){
System.out.print(hourlyTemps[i]);
if (i >0){
System.out.print("*");
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!