Write an expression that prints \'Special number\" if specialNum is -99, 0, or 4
ID: 3880193 • Letter: W
Question
Write an expression that prints 'Special number" if specialNum is -99, 0, or 44. 1 import java.util.Scanner: 2 3 public class FindSpecialValue { 4 public static void main (String args) { 5 int specialNum = 0: 6 7 specialNum = 17: 8 9 if (specialNum = = -99) ||(specialNum == theta)||(specialNum == 44) { 10 System.out.println("Special number"): 11 } 12 else { 13 System.out.println('"Not special number"): 14 } 15 16 return: 17 } 18 } Failed to compile FindSpecialValue.java: 9: illegal start of expression if (specialNum == -99) || (specialNum == 0) || (specialNum == 44) { FindSpecialValue.java: 9: net a statement if (specialNum == -99) || (specialNum == 0) || (specialNum == 44) {Explanation / Answer
FindSpecialNumber.java
import java.util.Scanner;
public class FindSpecialNumber {
public static void main(String[] args) {
//Declaring variable
int number;
/*
* Creating an Scanner class object which is used to get the inputs
* entered by the user
*/
Scanner sc = new Scanner(System.in);
//getting the input entered by the user
System.out.print("Enter a number :");
number = sc.nextInt();
/* Based on user entered number
* check whether it is special number or not
*/
if (number == -99 || number == 0 || number == 44) {
System.out.println("Special Number");
} else {
System.out.println("Not Special Number");
}
}
}
_______________
Output#1:
Enter a number :-99
Special Number
Output#2:
Enter a number :49
Not Special Number
_____________Could you rate me well.Plz .Thank You
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.