Question: Integer arrays groceryItemPrices and costsToProduce are read from input, containing the prices and production costs of each grocery item. Initialize variable count with 0 .

Integer arrays groceryItemPrices and costsToProduce are read from input, containing the prices and production costs of each grocery item. Initialize variable count with 0. For each grocery item, increment count if a grocery item meets both of the following conditions:
Price is an odd integer.
Production cost is less than 20.
Lastly, output count followed by a newline.
Ex: For the input:
615282720
3010281723
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[] groceryItemPrices = new int[NUM_VALS];
int[] costsToProduce = new int[NUM_VALS];
int i;
int count;
for (i =0; i < NUM_VALS; ++i){
groceryItemPrices[i]= scnr.nextInt();
}
for (i =0; i < NUM_VALS; ++i){
costsToProduce[i]= scnr.nextInt();
}}

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 Databases Questions!