InterviewSolution
| 1. |
According to new Traffic rules ,Vehicles with Odd numbers can travel only in odd dates similarly Even numbered vehicles can travel only in Even dates .If any of the vehicle violates the rule will be fined Rs.100. If the same vehicle violates the rule twice the fine amount will be Rs.250 .The task is to calculate the total fine amount to be collected. Example : Input : [12,30,16,15,11] // vehicle number 4 // date output; 200 Explanation: Since 4 is even number only even numbered vehicle can travel in that day .Odd numbered vehicles are fined Rs.100.(11 and 15 violates).Total fine amount will be Rs.200 Constraints: The code should accept input during runtime ,It should satisfies multiple test cases. The code can be of any programming languages except PYTHON . (Java and C programming Recommended ). |
|
Answer» import java.util.*;public class HelloWorld{ public static void main(String... args){ Scanner s = new Scanner(System.in); int[] intArray = Arrays.stream(s.nextLine().split(",")).mapToInt(Integer::parseInt).toArray(); int day = s.nextInt(); ArrayList |
|