write menu driven program to check whether the given program is duck or neon
plz answer correctly I need it urgently trust upon u
Answers
Answer:
import java.util.Scanner;
public class duckneon
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println("1. Duck number");
System.out.println("2.Neon number");
System.out.println("Enter your choice");
int n= sc.nextInt();
switch(n)
{
case 1:
{
System.out.print("Input a number : ");
String nstr = sc.nextLine();
int l = nstr.length();
int ctr = 0;
char chr;
for(int i=1;i<l;i++)
{
chr = nstr.charAt(i);
if(chr=='0')
ctr++;
}
char f = nstr.charAt(0);
if(ctr>0 && f!='0')
System.out.println("Duck number");
else
System.out.println("Not a duck number");
}
case 2:
{
int z,square,sum=0;
//you have to enter number here.
System.out.print("Enter the number: " );
z=sc.nextInt();
//calculate square.
square=z*z;
while(square>0)
{
sum=sum+square%10;
square=square/10;
}
//condition for checking sum is equal or not.
if(sum==z)
System.out.println("Its a Neon number.");
else
System.out.println("Its not a Neon number.");
}
default:
System.out.println("Wrong choice");
}
}
}
Explanation:
Please please mark me as brainliest