You are on page 1of 6

MOBILE APP DEVELOPMENT USING ANDROID

ASSIGNMENT – I

Submitted by: MOHAN RAM.G, 15F070

1) ODD OR EVEN NUMBER:

import java.util.Scanner;
public class Oddeven
{
public static void main(String s[])
{
Scanner sc=new Scanner(System.in);
int i=sc.nextInt();
switch (i%2)
{
case 1:
System.out.println("The given number is Odd");
break;
default:
System.out.println("The given number is Even");
}
}
}

2) SIGN OF NUMBER:

import java.util.Scanner;
public class Sign
{
public static void main(String s[])
{
int i;
Scanner sc=new Scanner(System.in);
i=sc.nextInt();
if(i<0)
System.out.println("The given number is Negatiive");
else if(i>0)
System.out.println("The given number is Positive");
else
System.out.println("The given number is zero");
}
}

3) MEAN OF NUMBERS:

import java.util.Scanner;
public class Mean
{
public static void main(String s[])
{
Scanner sc=new Scanner(System.in);
int i=sc.nextInt();
int j=sc.nextInt();
int k=sc.nextInt();
System.out.println("Mean of given numbers is: "+(i+j+k)/3);
}
}

4) MAXIMUM BETWEEN NUMBERS:

import java.util.Scanner;
public class Maximum
{
public static void main(String s[])
{
Scanner sc=new Scanner(System.in);
int i=sc.nextInt();
int j=sc.nextInt();
if(i<j)
System.out.println(j+" is the maximum between the two");
else if(i>j)
System.out.println(i+" is the maximum between the two");
else
System.out.println("Both numbers are same");
}
}

5) LOOP 1:

public class loop1


{
public static void main(String s[])
{
int i=1;
while(i<=9)
{
System.out.println(i);
i+=2;
}
}
}

6) LOOP 2:

public class loop2


{
public static void main(String s[])
{
int i=2,j=0;
while(i<=20)
{
i=i+j;
if(i>10)
System.out.println(i-2);

else
System.out.println(i);
j+=2;
}
}
}

7) LOOP 3:

package assignment;
public class loop3
{
public static void main(String s[])
{
int i=1;
while(i<=17)
{
System.out.println(i);
i+=4;
}
}
}
8) LOOP 4:

public class loop4


{
public static void main(String s[])
{
int i=0,j=1;
while(i<25)
{
i+=j;
System.out.println(i);
j+=2;
}
}
}

9) LOOP 5:

public class loop5


{
public static void main(String s[])
{
int i=2,j=4;
while(j>=0)
{
System.out.println(i);
i+=j;
j--;
}
}
}
10) LOOP 6:

public class loop6


{
public static void main(String s[])
{
int i=15,j=2;
while(i>0)
{
System.out.println(i);
i-=j;
j*=2;
}
}
}

You might also like