Write an expression using Boolean operators that prints "Special number" if special_num is -99, 0, or 44.

See Answers (1)

Accepted Answer

A sample expression that uses Boolean operators that prints "Special number" if special_num is -99, 0, or 44 is given below:The Programimport java.util.Scanner;import java.io.*;public class Test{    public static void main(String[]args) throws IOException    {        File file = new File("SNUMS.INP");        Scanner inputFile = new Scanner(file);        int order = 1;        int i = 1;       int[] special = new int[1000000+1];        // Write all 10^6 special numbers into an array named "special"        while (order <= 1000000)        {            if (specialNumber(i) == true)            {               special[order] = i;                order++;            }            i++;        }        // Write the result to file        PrintWriter outputFile = new PrintWriter("SNUMS.OUT");        outputFile.println(special[inputFile.nextInt()]);        while (inputFile.hasNext())            outputFile.println(special[inputFile.nextInt()]);        outputFile.close();    }    public static boolean specialNumber(int i)    {        // This method check whether the number is a special number        boolean specialNumber = false;       byte count=0;        long sum=0;        while (i != 0)        {            sum = sum + (i % 10);            count++;            i = i / 10;        }        if (sum % count == 0) return true;        else return false;     }}Read more about boolean operators here:https://brainly.com/question/5029736#SPJ1

Related Question in Computers and Technology