Ask Question
8 November, 06:26

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 November, 08:02
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers