Ask Question
22 May, 20:35

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. 22 May, 22:42
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers