1.DividesSelf
/*Write your code here */
import java.util.*;
class mno{
public static void main(String args[]){
Scanner s=new Scanner(System.in);
int num=s.nextInt();
int i=num;
while(i!=0){
int d=i%10;
if(i==0 || num%d!=0) System.out.print("false");
else System.out.print("true");
i/=10;
break;
}
}
}
2.Reverse
/*Write your code here */
import java.util.*;
class mno{
public static void main(String args[]){
Scanner s=new Scanner(System.in);
int n,temp=0,rem=0;n=s.nextInt();
do{ temp=n%10;rem=rem*10+temp;n/=10; }while(n>0);
System.out.println(rem);
}
}
3.Mini Matrix Calculator
/*Write your code here */
import java.util.*;
class mno{
public static void main(String args[]){
Scanner s=new Scanner(System.in);
int[][] a=new int[3][3];
int[][] b=new int[3][3];
int i,j;
for(i=0;i<3;i++){
for(j=0;j<3;j++){
a[i][j]=s.nextInt();
}
}
for(i=0;i<3;i++){
for(j=0;j<3;j++){
b[i][j]=s.nextInt();
}
}
for(i=0;i<3;i++){
for(j=0;j<3;j++){
System.out.print(a[i][j]+b[i][j]);
if(j<2){
System.out.print(" ");
}
}
System.out.println(" ");
}
System.out.println("\n");
for(i=0;i<3;i++){
for(j=0;j<3;j++){
System.out.print(a[i][j]-b[i][j]);
if(j<2){
System.out.print(" ");
}
}
System.out.println("\n");
}
}
}
4.Error evaluation
/*Write your code here */
import java.util.*;
class imn{
public static void main(String args[]){
Scanner n=new Scanner(System.in);
double d=n.nextDouble();
double a=(d+d)+((d*d)/100);
System.out.println(a);
}
}
5.ATM Cash Withdrawal
/*Write your code here */
import java.util.*;
class mno{
public static void main(String args[]){
Scanner s=new Scanner(System.in);
int x=s.nextInt();
int y=s.nextInt();
if(x%100==0)
{
if(x<y)
{
int z=(y-(x+5));
System.out.println(z);
}
else
{
System.out.println(y);
}
}
else
System.out.println(y);
}
}
No comments:
Post a Comment