write a program to accept a number and check whether it is a super six number or not. a super six no.is a no. which contains at least two sixes.
Answers
Answer:
import java.util.Scanner;
public class Main
{
static boolean isSuperSix(int n){
int six = 0;
int temp = n;
while(temp!=0){
int r = temp%10;
if(r == 6){
six++;
}
temp/=10;
}
if(six >= 2){
return true;
}
return false;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number:");
int n = sc.nextInt();
if(isSuperSix(n)){
System.out.println(n + " is a super six number");
}
else{
System.out.println(n + " is not a super six number");
}
}
}
Explanation:
34567982456789245678