Computer Science, asked by babeysekara, 11 months ago

Write a MARIE program that accepts an integer from the user, and if it is a prime number the program will output 1, otherwise, the program will output 0.


Examples:


If the user input is 17, the output would be 1


If the user input is 2, the output would be 1


If the user input is 15, the output would be 0


If the user input is -2, the output would be 0




You should write and run the program using MARIE simulator.

Answers

Answered by ksjxjsj
3

Answer:

I don't know much about it and I will be there for you to get your own ❤️❤️❤️❤️❤️

Answered by franktheruler
0

Answer:

Explanation:

import java.io.*;

class prime

       {

          public staticvoid main ( String args [] ) throws IOException

               {

                     BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) );

int count = 0 ;

System. out. println ( " Enter a number " );

int n = Integer . parseInt (in . readLine ( ) );

for ( int i = 0 ; i < = n ; i + +)

{

       if ( n % i = = 0 )

         {

                count = count + 1 ;

          }

}

if ( count < = 2 )

{

     System. out. println ( " It is a prime number " );

}

else

{

           System. out. println ( " It is not a prime number " );

}

                          }

       }

Similar questions