Question: Integer arrays busTags and gasRemaining are read from input, containing the tags and remaining gas of each bus. Initialize variable count with 0 . For
Integer arrays busTags and gasRemaining are read from input, containing the tags and remaining gas of each bus. Initialize variable count with For each bus, increment count if a bus meets both of the following conditions:
Tag is less than or equal to
Remaining gas is an odd integer.
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 busTags new intNUMVALS;
int gasRemaining new intNUMVALS;
int i;
int count;
for i ; i NUMVALS; i
busTagsi scnrnextInt;
for i ; i NUMVALS; i
gasRemainingi scnrnextInt;
Your code goes here
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
