What is the max value of 24sinx + 10cosx ?
Write a program in JAVA to print the following in switch case only :
case 1 : print the reverse of number
case 2 : remove zeroes.
case 3 : check whether the number is pallindrome number or not .
Answers
What is the maximum value of 24 sin x + 10 cos x ?
Answer :
For an equation a sin x + b cos x :
Maximum value = √ ( a² + b² )
Given : a = 24
b = 10
Maximum value = √ ( 24² + 10² )
= √ ( 576 + 100 )
= √ 676
= ± 26
The maximum value can be 26 .
CODE :
import java.util.*;
class switch_mania
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter a number");
int n=sc.nextInt();
System.out.println("Enter 1 to print reverse , 2 to print number without zeroes and 3 to check pallindrome ");
int ch=sc.nextInt();
switch(ch)
{
case 1:
while(n>0)
{
int d=n%10;
rev=(rev*10)+d;
n=n/10;
}
System.out.println("Reverse of the number is "+rev);
break;
case 2:
System.out.println("The zeroes are removed");
while(n>0)
{
int d=n%10;
rev=(rev*10)+d;
n=n/10;
}
while(rev>0)
{
int d=rev%10;
if(d!=0)
{
System,out.print(d);
}
rev=rev/10;
}
break;
case 3:
int cpy=n;
while(n>0)
{
int d=n%10;
rev=(rev*10)+d;
n=n/10;
}
if(cpy==rev)
{
System.out.println("Pallindrome number");
}
else
{
System.out.println("Not a pallindrome number");
}
break;
}
default:
System.out.println("Invalid choice");
}
}
}
Thank you !