Ask Question
8 January, 21:23

Assign to the variable boolean 'primesecond' the value true if the second leading (just after the most significant) decimal digit of the value of an int variable 'n' is 2,3,5 or 7; otherwise assign 'primesecond' the value false. assume 'primesecond' and 'n' are already declared and that 'n' has already been assigned a value. so if n's value is 58047 primesecond will be false because the second leading digit of 58047 is 8 which is not 2 or 3 or 5 or 7.

+4
Answers (1)
  1. 8 January, 21:51
    0
    Here you go,

    Program:

    public class SecondPrime {

    public static void main (String[] args) {

    int n=58047;

    boolean primeSecond;

    while (n > 9)

    {

    n%=10000;

    n/=1000;

    }

    if ((n==2) || (n==3) || (n==5) || (n==7))

    {

    primeSecond=true;

    }

    else

    primeSecond = false;

    System. out. println ("/nPrime Second is: "+primeSecond);

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Assign to the variable boolean 'primesecond' the value true if the second leading (just after the most significant) decimal digit of the ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers