TCS FIRST CHALLANGE "CODE CHALLANGE"
1)
/* input=12
12/2 + 12/3 + 12/4 =13
output =13
*/
class challenge11
{
public static void main(String arg[])
{
System.out.println("menu");
System.out.println("1:transection");
System.out.println("2:exit");
try
{
int input=10;
int choice=Integer.parseInt(arg[0]);
if(choice==1)
{
input=Integer.parseInt(arg[1]);
}
if(input<2)
{
System.out.println("minimum 2 number input");
}
else if(input >1000000000)
{
System.out.println(" maximum 1000000000 number input");
}
else
{
switch(choice)
{
case 1:
int ans=input/2+input/3+input/4;
System.out.println("ans is:"+ans);
break;
case 2:
System.out.println("Exit");
break;
default :
System.out.println("Plz choose any");
}
}
}
catch(Exception e)
{
System.out.println("any input not null ");
System.out.println("not Maximum value for 100000000 ");
System.out.println("not input string");
}
}
}
ALGORITHM
Step 1: ->Start
Step 2:
->Two variable declare 1)input, 2)choice.
->Enter two value for input and choice.
Step 3:
->Enter choice 1 then transection performed.
->Enter choice 2 then exit.
if choice==1 then
calculation the input value
if input<2 then
goto step 4;
else if input length is greater than 10 then
goto step 4;
end if;
end if;
if choice==2 then
goto step 7
end if;
Step 4:
->Check validation for input value to 2 minimum and 1,000000000 maximum.
Step 5:
->Check choice value to switch case.
step 6:
->calculate input variable value.
->print calculation answer
step 7: End
2)
class challenge12
{
public static void main(String arg[])
{
try
{
int principle=Integer.parseInt(arg[0]);
int rate=Integer.parseInt(arg[1]);
int year=Integer.parseInt(arg[2]);
float ans=principle*rate*year/100;
System.out.println("ans is:-"+ans);
}
catch(Exception e)
{
System.out.println("no blank input allow");
System.out.println("no String input allow");
}
}
}
Thanks & Regards,
Dipak N. Mangnani | BCA |
student of sssdiit college(M): +91 9033790214