Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Luc Perkins, Eric Redmond, Jim Wilson

2nd Edition

1680502530, 978-1680502534

More Books

Students also viewed these Databases questions