Can you convert the code into java?
#include<vector>
#include<iostream>
auto f=
[](auto m,int&r){
r=1; //set return flag to true
for(auto a:m) //for each element
for(auto b:m) //check with second element
if (a.second==b.first){ //do they chain?
int i=0; //flag for local transitivity
for(auto c:m) //search for a third element
i+=a.first==c.first&&b.second==c.second;
r*=i>0; //multiply with flag>0, resulting in 0 forever if one was not found
}
}
;
int main(){
std::vector<std::pair<int,int>> m={
{1, 2}, {2, 4}, {6, 5}, {1, 4}
};
int r;
f(m,r);
std::cout << r << std::endl;
m.emplace_back(3,6);
f(m,r);
std::cout << r << std::endl;
m.emplace_back(3,5);
f(m,r);
std::cout << r << std::endl;
}Question 1
Write down the method isPrime(int number), which accepts an positive integer and return a boolean
value if the number is Prime or not.
Question 2
Write a method called printUnique that accepts one integer array as argument, and print all unique elements
form the array. E.g. {5,6,7,8,9,8,7,6,5} (9 is unique).
Question 3
Given two arrays of same size and type, arr1={1,2,3,4,5} and arr2={6,7,8,9,10} calculate the
difference of all values in the array and your operation would be like (Arr2 - Arr1)
I = P*N*R . The total amount to repay will be A = P + I
Input Commands
There are 3 input commands LOAN, PAYMENT, BALANCE
LOAN
Format - LOAN BANK_NAME BORROWER_NAME PRINCIPAL NO_OF_YEARS RATE_OF_INTEREST
Example- LOAN IDIDI Dale 10000 5 4 means a loan amount of 10000 is paid to Dale by IDIDI for a tenure of 5 years at 4% rate of interest.
PAYMENT
Format - PAYMENT BANK_NAME BORROWER_NAME LUMP_SUM_AMOUNT EMI_NO
BALANCE
Input format - BALANCE BANK_NAME BORROWER_NAME EMI_NO
Output format - BANK_NAME BORROWER_NAME AMOUNT_PAID NO_OF_EMIS_LEFT
Assumptions
1. Repayments will be paid every month as EMIs until the total amount is recovered.
2. Lump sum amounts can be paid at any point of time before the end of tenure.
3. The EMI amount will be always ceiled to the nearest integer.
INPUT:
LOAN IDIDI Dale 10000 5 4
LOAN MBI Harry 2000 2 2
BALANCE IDIDI Dale 5
BALANCE IDIDI Dale 40
BALANCE MBI Harry 12
BALANCE MBI Harry 0
OUTPUT:
IDIDI Dale 1000 55
IDIDI Dale 8000 20
MBI Harry 1044 12
MBI Harry 0 24
In a class test the teacher announces the marks (negative marking is allowed) of n (n>0) students. A student can achieve maximum 100 marks. Write a python function print_marks(*marks) that takes number of students, marks of students and return the marks and check the marks are valid or not. If valid then it calls the recursive function rec_Sort(*marks) which returns the students marks as a comma-separated string with elements in ascending order. (You can use of built-in function max ()/min() to do this)
Write a python function Sum(ele) which takes a comma-separated string of numbers and returns the reverse of the sum of the smallest and largest numbers in the given list as shown in the example. For example, for the list 10, 23, 14, 25, the sum of smallest and largest numbers is 35. And the reverse of 35 is 53.
NOTE:
Artificial Mouse Population satisfying the following conditions:
Write a function gen_population_series (x, y, n) which takes initial population as x, y and a positive integer number n as number of months and returns number of mouses produced in each month till nth month in string format using recursion.
· Declare an array as Car with size 10.
· Take 10 Car’s information from user and store them in specified array.
· Call findCarList method from Main class to get all cars information related to a given model name and display then within this method.
· Model name should be taken from Main class and pass to findCarList method as argument as well as Car array (with size 10).
Design findCarList method in Car classas follows:
· it will take a model(car model) as parameter and array of cars (with size 10)
· displays List of cars for the given model from the list .
· If there are no cars, then shows “No cars found”.
Input numbers from the user and find the sum of all those input numbers until the user inputs zero. In other means, the loop should end when the user enters 0. Finally, display the sum of all those numbers entered by the user
How to determine the set is symmetric using java code?
Take input of your registration number(19120856) in the University. Write a program to print all the prime numbers digits in your registration number.