CHALLENGE ACTIVITY 5.5.1: Multiple arrays. 474382.3411108.qx3zqy7 Jump to level 1 Integer arrays unitCosts and stockRecords are read from input, containing the costs and stock records of each unit. Initialize variable count with 0. For each unit, increment count if an unit meets both of the following conditions: Cost is greater than or equal to 20. Stock record is less than or equal to 20. Lastly, output count followed by a newline. Ex: For the input: 17 23 26 15 8 26 10 12 25 28 then the output is: 2 import java.util.Scanner; public class CombineArrays { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); final int NUM_VALS = 5; int[] unitCosts = new int[NUM_VALS]; int[] stockRecords = new int[NUM_VALS]; int i; int count; for (i = 0; i < NUM_VALS; ++i) { unitCosts[i] = scnr.nextInt(); } for (i = 0; i < NUM_VALS; ++i) { stockRecords[i] = scnr.nextInt(); } /* Your code goes here */ } }
Need help and Java please
CHALLENGE ACTIVITY 5.5.1: Multiple arrays. 474382.3411108.qx3zqy7 Jump to level 1 Integer arrays unitCosts and stockRecords are read from input, containing the costs and stock records of each unit. Initialize variable count with 0. For each unit, increment count if an unit meets both of the following conditions: Cost is greater than or equal to 20. Stock record is less than or equal to 20. Lastly, output count followed by a newline. Ex: For the input: 17 23 26 15 8 26 10 12 25 28 then the output is: 2
import java.util.Scanner;
public class CombineArrays {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
final int NUM_VALS = 5;
int[] unitCosts = new int[NUM_VALS];
int[] stockRecords = new int[NUM_VALS];
int i;
int count;
for (i = 0; i < NUM_VALS; ++i) {
unitCosts[i] = scnr.nextInt();
}
for (i = 0; i < NUM_VALS; ++i) {
stockRecords[i] = scnr.nextInt();
}
/* Your code goes here */
}
}
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images