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 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
Lastly, output count followed by a newline.
Ex: For the input:
then the output is:
import java.util.Scanner;
public class CombineArrays
public static void mainString args
Scanner scnr new ScannerSystemin;
final int NUMVALS ;
int groceryItemPrices new intNUMVALS;
int costsToProduce new intNUMVALS;
int i;
int count;
for i ; i NUMVALS; i
groceryItemPricesi scnrnextInt;
for i ; i NUMVALS; i
costsToProducei scnrnextInt;
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
