Answer to Question #321301 in Java | JSP | JSF for Tzu

Question #321301

An owner of an auto repair shop wishes to organize his team of mechanics at the beginning of the day. To make the distribution of work equal, he organizes cars with an even amount of faults into bay 1 and cars with an odd amount of faults into bay 2. There are nine cars in total Write the pseudocode for the problem, then write a Java program to separate the even and odd number of car faults. Have all even numbers displayed first, then odd numbers at the end. The repairs required for each car are as follows. 18, 14, 12, 6, 4, 21, 19, 9, 3 Hint: WHILE LOOPS and IF.



1
Expert's answer
2022-05-03T14:19:29-0400

public static void main(String[] args){

    int[] inArray = {18, 14, 12, 6, 4, 21, 19, 9, 3};

    int[] evenArray = Arrays.stream(inArray).filter(s -> s % 2 == 0).toArray();

    int[] oddArray = Arrays.stream(inArray).filter(s -> s % 2 == 1).toArray();


    System.out.println(Arrays.toString(evenArray));

    System.out.println(Arrays.toString(oddArray));

  }


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS