Answer to Question #293205 in Java | JSP | JSF for Bomba

Question #293205

Can you change this code into java code



#include <iostream>

using namespace std;

int countReflexive(int n){

int ans = 1 << (n*n - n);

return ans;

}

int main(){

int n ;

cin >> n ; // taking input n from the user using std cin.

int result = countReflexive(n); // calling function to calculate number of reflexive relations

cout << "Number of reflexive relations on set: " << result ; // printing the answer

return 0;

}


1
Expert's answer
2022-02-02T11:48:06-0500
import java.util.Scanner;


class Main {
   static int countReflexive(int n){
    int ans = 1 << (n*n - n);
    return ans;
   }
public static void main(String[] args) {
        Scanner keyBoard = new Scanner(System.in);
        int n ;
        n =keyBoard.nextInt(); // taking input n from the user using std cin.
       int result = countReflexive(n); // calling function to calculate number of reflexive relations
        System.out.println("Number of reflexive relations on set: " + result); // printing the answer
        keyBoard.close();
    }
}

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