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 0. For each bus, increment count if a bus meets both of the following conditions:
Tag is less than or equal to 150.
Remaining gas is an odd integer.
Lastly, output count followed by a newline.
Ex: For the input:
102118174180159
1139182234
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[] busTags = new int[NUM_VALS];
int[] gasRemaining = new int[NUM_VALS];
int i;
int count;
for (i =0; i < NUM_VALS; ++i){
busTags[i]= scnr.nextInt();
}
for (i =0; i < NUM_VALS; ++i){
gasRemaining[i]= scnr.nextInt();
}
/* Your code goes here */
}
}

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!