You are on page 1of 9

/*Question1-WAP to find whether a number is even or odd*/

/*Developed By- Tilak Singh

Rollno-2102900100160*/

import java.util.Scanner;

public class even_odd{

public static void main(String[] args) {

System.out.println("Enter the number:");

Scanner sc=new Scanner (System.in);

int x=sc.nextInt();

if(x%2==0)

System.out.println("It is even number:");

else

System.out.println("It is an odd number:");

/*Question2-WAP to find largest among three numbers */

/*Developed By- Tilak Singh

Rollno-2102900100160*/

import java.util.Scanner;

public class largest {

public static void main(String[] args) {

System.out.println("Enter the numbers:");

Scanner sc = new Scanner(System.in);

int num1 = sc.nextInt();

System.out.println("Enter the numbers:");

int num2 = sc.nextInt();


System.out.println("Enter the numbers:");

int num3 = sc.nextInt();

if (num1 > num2 && num1 > num3) {

System.out.println("The greatest no.is " + num1);

} else if (num2 > num3) {

System.out.println("The Largest no.is " + num2);

} else {

System.out.println("The greater no.is " + num3);

/*Question3-WAP to check whether the triangle is equilateral ,scanlene or


isosceles. */

/*Developed By- Tilak Singh

Rollno-2102900100160*/

import java.util.Scanner;

public class triangle{

public static void main(String[] args) {

System.out.println("Enter the side1 of triangles:");

Scanner sc=new Scanner(System.in);

int a=sc.nextInt();

System.out.println("Enter the side2 of triangles:");

int b=sc.nextInt();

System.out.println("Enter the side3 of triangles:");

int c=sc.nextInt();

if(a==b && a==c){

System.out.println("It is equilateral triangle.");


}

else if(a==b || b==c || a==c){

System.out.println("It is isosceles triangle.");

else{

System.out.println("It is scanlene triangle");

/*Question4-WAP that a read a floating point number and prints zero if the number
is zero. Otherwise print negative or positive. */

/*Developed By- Tilak Singh

Rollno-2102900100160*/

import java.util.Scanner;

public class floating{

public static void main(String[] args) {

System.out.println("Enter the number:");

Scanner sc=new Scanner(System.in);

float num =sc.nextFloat();

if(num==0)

System.out.println("It is zero.");

else if(num>0)

System.out.println("It is positive");

else

System.out.println("It is negative:");

}
}

/*Question5-WAP that reads to floating number and test whether they are same upto
3 decimal places. */

/*Developed By- Tilak Singh

Rollno-2102900100160*/

import java.util.Scanner;

public class floating1 {

public static void main(String[] args) {

System.out.println("enter the num1");

Scanner sc = new Scanner(System.in);

System.out.println("enter the num2");

float a = sc.nextFloat();

float b = sc.nextFloat();

int a1 = (int) a * 1000;

int b1 = (int) b * 1000;

if (a1 == b1)

System.out.println("equal");

else

System.out.println("not equal");

/*Question6-WAP that take 3 numbers as input and print "all are equal" if all are
equal, "all are different" if all 3 number are different and neither all or equal
or different " otherwise. */

/*Developed By- Tilak Singh


Rollno-2102900100160*/

import java.util.Scanner;

public class equal {

public static void main(String[] args) {

System.out.println("Enter the num1");

Scanner sc = new Scanner(System.in);

int a = sc.nextInt();

System.out.println("Enter the num2");

int b = sc.nextInt();

System.out.println("Enter the num3");

int c = sc.nextInt();

if (a == b && a == c) {

System.out.println("all numbers are equal");

else

if (a != b && a != c && b != c) {

System.out.println("all numbers are differnt");

else {

System.out.println("neither equal nor same");

}
/*Question7-WAP that takes 3 number as input and print increasing if the number
are in increasing order,decreasing if the numbers are in decreasing
order"otherwise. */

/*Developed By- Tilak Singh

Rollno-2102900100160*/

import java.util.Scanner;

public class inc_dec {

public static void main(String[] args) {

System.out.println("Enter the num1");

Scanner sc = new Scanner(System.in);

int a = sc.nextInt();

System.out.println("Enter the num2");

int b = sc.nextInt();

System.out.println("Enter the num3");

int c = sc.nextInt();

if (b > a && c > b)

System.out.println("The number are in Increasing order");

else if (a > b && b > c)

System.out.println("The number are in decreasing order");

else

System.out.println("The number are neither increasing nor decreasing


order");

}
/*Question8-WAP to print day name of a weekday number starting sunday as day 1.*/

/*Developed By- Tilak Singh

Rollno-2102900100160*/

import java.util.Scanner;

public interface week {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.println("Enter the no. to know the day:");

int no = sc.nextInt();

switch (no) {

case 1:

System.out.println("Sunday");

break;

case 2:

System.out.println("Monday");

break;

case 3:

System.out.println("Tuesday");

break;

case 4:

System.out.println("Wednesday");

break;

case 5:

System.out.println("Thursday");

break;

case 6:

System.out.println("Friday");
break;

case 7:

System.out.println("Saturday");

break;

default:

System.out.println("Invalid Input");

/*Question9-WAP to create a basic calculator using switch case. */

/*Developed By- Tilak Singh

Rollno-2102900100160*/

import java.util.Scanner;

public class calculator {

public static void main(String[] args) {

System.out.println("Enter the num1");

Scanner sc = new Scanner(System.in);

int a = sc.nextInt();

System.out.println("Enter the num2");

int b = sc.nextInt();

System.out.println("Choose the operation:");

char ch = sc.next().charAt(0);

switch (ch) {

case '+':

System.out.println("Sum of " + a + " and " + b + ": " + (a + b));

break;

case '-':
System.out.println("Difference of " + a + " and " + b + ": " + (a - b));

break;

case '*':

System.out.println("Multiplication of " + a + " and " + b + ": " + (a *


b));

break;

case '/':

System.out.println("Division of " + a + " and " + b + ": " + (a / b));

break;

default:

System.out.println("Invalid Input:");

You might also like