85

It is used to solve a condition-based problem, the ternary operator only provides a single statement under the true condition and false condition but the conditional statement provides a separate block for true condition and false condition using the if, else, and else if statement.

Type of Conditional Statement:-

1)  Simple If:-  It is used to display result based on true condition,
if(condition)
statement;
or
if(condition)
{
multiple statements;
}
note:-  we should use {} when we want to contain multiple statements.
Q) WAP to display "You are Qualintine for 15 days " if a person is Covid positive otherwise not display any message?
Solution 1st:-
import java.util.Scanner;
class CovidResult
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter covid result");
String s;
s = sc.next();
if(s.equals("Positive"))
System.out.println("You are quarantine for 15 days");
}
}
Solution 2nd:-
import java.util.Scanner;
class CovidTest
{
public static void main(String args[])
{

System.out.println("Enter covid result");
if(new Scanner(System.in).next().equals("positive"))
{
System.out.println("You are quarantine for 15 days");
}
}
}
WAP to increase the salary of employees from 500, if the salary is less than 10000 otherwise the same salaries will print?
class Salary
{
public static void main(String args[])
{
int sal=8000;
if(sal<10000)
sal=sal+500;

System.out.println(sal);
}
}
/*WAP to pass student by grace if the entered subject mark is >28 and <33 otherwise same mark
will display.*/
import java.util.Scanner;
class CalculateMarks
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter number");
int mark,g;
mark = sc.nextInt();
if(mark>=28 && mark<33)
{
g = 33-mark;
mark =mark+g;
System.out.println("Grace marks is "+g);
}
System.out.println("mark is "+mark);
}
}
2)  If--else:-
Using this we can create a program when the condition is true and false both "if" block for the true condition and "else" block for the false condition.
Syntax:-
if(condition)
{
Statements;
}
else
{
Statements;
WAP to calculate square if the number is odd and calculate the cube if the number is even?
class Checksq
{
public static void main(String args[])
{
int num=4;
int res=0;
if(num%2==0)
res=num*num*num;
else
res=num*num;
System.out.println(res);
}
}
3) Nested If--else:-
We will solve more than one condition using nested if-else, we will create more than one if-else statement using a nested sequence to solve multiple conditions.
Syntax:-
if(condition)
{
if(condition)
{

}
else
{
}
}
else
{
if(condition)
{
}
else
{
}
}
WAP to calculate the greatest number?
class Greatest
{
public static void main(String args[])
{
int a=2,b=34,c=5;
if(a>b)
{
if(a>c)
System.out.println("a is greater");
else
System.out.println("c is greater");
}
else
{
if(b>c)
System.out.println("b is greatest");
else
System.out.println("c is greatest");

}
}
}
WAP to calculate greatest using four different numbers?
class Greatest
{
public static void main(String args[])
{
int a=10000,b=2000,c=3000,d=4000;
if(a>b)
{
if(a>c)
{
if(a>d)
System.out.println("a is greatest");
else
System.out.println("d is greatest");
}
else
{
if(c>d)
System.out.println("c is greatest");
else
System.out.println("d is greatest");
}
}
else
{
if(b>c)
{
if(b>d)
System.out.println("b is greatest");
else
System.out.println("d is greatest");
}
else
{
if(c>d)
System.out.println("c is greatest");
else
System.out.println("d is greatest");
}
}
}
}

WAP to check vowel and consonant?
/* WAP to check vowel and consonant */
import java.util.Scanner;
class CheckVC
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
char ch;
System.out.println("Enter char");
ch= sc.next().charAt(0);
String s= "";
if(ch=='a')
s = "Vowel";
else
{
if(ch=='e')
s = "Vowel";
else
{
if(ch=='i')
s = "Vowel";
else
{
if(ch=='o')
s = "Vowel";
else
{
if(ch=='u')
s = "Vowel";
else
s = "Consonent";
}
}

}
}
System.out.println(s);
}
}
#problem
class Eligible
{
public static void main(String args[])
{
int age=21;
String stream = "IT";
if(age>18)
{
if(stream=="CS")
{
System.out.println("You are eligible");
}
else
{
System.out.println("NON CS ");
}
}
else
{
System.out.println("Age should be above 18+");
}

}
}
Limitation:-
Its structure is complex for multiple conditions, for example, if we want to check maximum using five different numbers?
We can create a conditional-based program without using logical operators.
4) Ladder If--Else or Else If Block:-
It will work step by step means if the first condition will true then it will be executed when it will be false then the next condition will be checked and finally, if no one condition will be true then else statement will be executed.
we will use if, else if, and else statement using Ladder If--Else.
Syntax of Ladder if else if
if(condition)
{
Statement
}
else if(condition)
{
Statement;
}
...
else
{
Statement;
}
WAP to check the greatest number using Ladder if-else?
class Greatest
{
public static void main(String args[])
{
int a=10000,b=3000,c=2000;
if(a>b && a>c)
System.out.println("a is greatest");
else if(b>c)
System.out.println("b is greatest");
else
System.out.println("c is greatest");
}
}
WAP to check greatest using four different numbers?
class Greatest
{
public static void main(String args[])
{
int a=1000,b=2000,c=3000,d=4000;
if(a>b && a>c && a>d)
System.out.println("a is greatest");
else if (b>c && b>d)
System.out.println("b is greatest");
else if(c>d)
System.out.println("c is greatest");
else
System.out.println("d is greatest");
}
}
WAP to check vowel and consonant using Ladder if--else:-
/* WAP to check vowel and consonent */
import java.util.Scanner;
class CheckVC
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
char ch;
System.out.println("Enter char");
ch= sc.next().charAt(0);
String s= "";
if(ch=='a')
s = "Vowel";
else if(ch=='e')
s = "Vowel";
else if(ch=='i')
s = "Vowel";
else if(ch=='o')
s = "Vowel";
else if(ch=='u')
s = "Vowel";
else
s = "Consonent";
System.out.println(s);
}
}
5) Multiple If:-
We can write more than one if statement to solve multiple conditions with multiple results.
Syntax of Multiple If:-
if(condition)
{
Statement;
}
if(condition)
{
Statement;
}
if(condition)
{
statement;
}
WAP to check divisibility of numbers that number is divisible by 3,5 and 9 with all combinations?
int num=27
if(num%3==0)
System.out.println("Divisible by 3");
if(num%5==0)
System.out.println("Divisible by 5");
if(num%9==0)
System.out.println("Divisible by 9");
Assignment of If--else:
Q1)  WAP to display yes, no, and cancel when the user assigns y,n, and c?
char ch='y';
if(ch=='y')
System.out.println("Yes")
else if(ch=='n')
System.out.println("NO");
else if(ch=='c')
System.out.println("Cancel")
else
System.out.println("Other");
Q2)  WAP to check 1 digit, 2 digits,3 digits, and above 3 digit number?
Q3) WAP to find the middle number in three different numbers?
class Checkmiddle
{
public static void main(String args[])
{
int a=10,b=12,c=340;
if(a>b && a<c || a<b && a>c)
System.out.println("a is middle number");
else if(b>a && b<c || b<a && b>c)
System.out.println("b is middle number");
else
System.out.println("c is middle number");
}
}
Q4) WAP to create a mark-sheet of Students using five different subjects with the following condition?
1)  All Subject Marks Should be 0 to 100.
2) If only Subject Mark is <33 Then Student will Suppl
3) If Minimum Two Subjects Marks is <33 Then Student Will Fail
4) IF all Subject Marks is > 33 then percentage and division should be calculated.
5)  IF only one subject Mark is >28 and <33 then 5 grace marks will be applied and the student will be passing by grace.
6)  Display Grace Subject Name, Distinction Subject name, Supp Subject name, and Failed Subject name.
The solution of This Program:-
class Marksheet
{
public static void main(String args[])
{
int m1=85,m2=86,m3=67,m4=68,m5=84;
if((m1>=0 && m1<=100) && (m2>=0 && m2<=100) && (m3>=0 && m3<=100) && (m4>=0 &&
m4<=100) && (m5>=0 && m5<=100))
{
int c=0;
int mark=0;
String sub="";
String dist="";
if(m1>=75)
{
dist+= " Physics ";
}
if(m2>=75)
{
dist+= " Chemistry ";
}
if(m3>=75)
{
dist+= " Maths ";
}
if(m4>=75)
{
dist+= " English ";
}
if(m5>=75)
{
dist+= " Hindi ";
}
if(m1<33)
{
sub+= " Physics ";
c++;
mark=m1;
}
if(m2<33)
{
sub+= " Chemistry ";
c++;
mark=m2;
}
if(m3<33)
{
sub+= " Maths ";
c++;
mark=m3;
}
if(m4<33)
{
sub+= " English ";
c++;
mark=m4;
}
if(m5<33)
{
sub+= " Hindi ";
c++;
mark=m5;
}
if(c==0 || (c==1 && mark>=28))
{
float per = (m1+m2+m3+m4+m5)/5;
if(per>33 && per<45)
System.out.println("Pass with third division");
else if(per<60)
System.out.println("Pass with second division");
else
System.out.println("Pass with first division");
if(c==1)
System.out.println("Pass by grace with "+(33-28)+ " Grace Subject name is
"+sub);
if(dist!="")
System.out.println("Distinction Subject name is "+dist);
}
else if(c==1)
{
System.out.println("Try again you are suppl in "+sub);
}
else
{
System.out.println("Sorry you have failed in "+sub);
}
}
else
{
System.out.println("entered subject mark should be 0 to 100");
}
}
}
Q) WAP to create ATM , First enter pin code with any hard code pin code value, if it is correct then provide ATM menu option to display Credit, Debit, CheckBalance and Withdrawal Option, when user press credit then amount will be added, in case of debit amount will reduce and in case of check balance amount will be visible to user's.

package oops;
import java.util.Scanner;
public class ATM {

public static void main(String[] args) {
int balance=12000;
String pin="1234";
char ch;
Scanner sc = new Scanner(System.in);
System.out.println("Pin code");
String pincode = sc.next();
if(pincode.equals(pin))
{
System.out.println("Press C for credit");
System.out.println("Press D for debit");
System.out.println("Press B for balance");
ch = sc.next().charAt(0);
if(ch=='C' || ch=='c')
{
System.out.println("Enter credit amount");
balance+=sc.nextInt();
System.out.println("After Credit Balance is "+balance);
}
else if(ch=='D' || ch=='d')
{
System.out.println("Enter debit amount");
balance-=sc.nextInt();
System.out.println("After Debit Balance is "+balance);
}
else if(ch=='b' || ch=='B')
{
System.out.println("Balance is "+balance);
}
else
{
System.out.println("Invalid Option");
}
}
else
{
System.out.println("Invalid Pincode");
}

}

}

Tags

1. //WAP to check 1 digit, 2 digit,3 digit and above 3 digit number?
import java.util.Scanner;
class digit
{
public static void main(String args[])
{
Scanner jk=new Scanner(System.in);
System.out.println("enter any number");
int in=jk.nextInt();
if(in>=0||in<=0)
{
in /=10;
if(in==0)
System.out.println("1 Digit");
}
if(in>0||in<0)
{
in/=10;
if(in==0)
System.out.println("2 Digits");

}
if(in>0||in<0)
{
in/=10;
if(in==0)
System.out.println("3 Digits");
else
System.out.println("more than 3 Digits");

}

}

}

2. Complete Solution of Marksheet program,Challenging program to you
class Marksheet
{
public static void main(String args[])
{
int m1=95,m2=75,m3=67,m4=37,m5=29;
String s1="phy",s2="chem",s3="maths",s4="english",s5="hindi";
float per;
String sub="";
String dist="";

if((m1>=0 && m1<=100) && (m2>=0 && m2<=100) && (m3>=0 && m3<=100) &&

(m4>=0 && m4<=100) && (m5>=0 && m5<=100))
{
int c=0;
int g=0;
if(m1<33)
{
g=m1;
sub=sub+s1+" ";
c++;
}
if(m2<33)
{
c++;
g=m2;
sub=sub+s2+" ";

}
if(m3<33)
{
g=m3;
c++;
sub=sub+s3+" ";
}
if(m4<33)
{
g=m4;
c++;
sub=sub+s4+" ";
}
if(m5<33)
{
g=m5;
c++;
sub=sub+s5+" ";
}
if(m1>=75)
dist = dist +s1 + " ";
if(m2>=75)
dist = dist +s2 + " ";
if(m3>=75)
dist = dist +s3+ " ";
if(m4>=75)
dist = dist +s4 + " ";
if(m5>=75)
dist = dist +s5 + " ";

if(c==0 || (c==1 && g>=28))
{
per=(m1+m2+m3+m4+m5)/5;
if(per>=33 && per<45)
System.out.println("Third division " + per + "%");
else if(per<60)
System.out.println("Second division " + per + "%");
else
System.out.println("First division " + per + "%");
if(g>0)
System.out.println("Pass by grace and grace mark is "+(33-g) +"

grace subject is "+sub);
if(dist!="")
System.out.println("Distinction Subject name is "+dist);

}
else if(c==1)
{

System.out.println("suppl subjects is "+sub);
}
else
{
System.out.println("fail subjects is "+sub);

}
}
else
{
System.out.println("Subject marks should be 0 to 100");

}

}

}

3. class Digits
{
public static void main(String args[])
{
int num=623673278;
int i=0;
int temp;
temp=num;
for(num=temp;num>=0;num--)
{
if(num!=0)
{
num=num/10;
i++;
}
}
System.out.println("The number is a "+i+" digit number.");
}
}

4. import java.util.Scanner;
class salaryofEmploy
{
public static void main(String[]arg)
{
Scanner sc=new Scanner(System.in);
System.out.println("salary of employ");
int salary=sc.nextInt();

if(salary<10000)
salary=salary+500;
System.out.println(salary);
}
}

5. import java.util.Scanner;
class ODDEVEN
{
public static void main(String[]arg)
{
Scanner sc=new Scanner(System.in);
System.out.println("enter number...");
int num=sc.nextInt();

if(num%2==0)
{
num=num*num*num;
System.out.println(num);
}
else
{
num=num*num;
System.out.println(num);
}
}
}

6. class Greatestnoabc
{
public static void main(String[]arg)
{
int a=2, b=8, c=34;

if(a>b)
{
if(a>c)
{
System.out.println("a is greater");
}
else
{
System.out.println("c is greater");
}
}
else
{
if(b>c)
{
System.out.println("b is greater");
}
else
{
System.out.println("c is greater");
}
}
}
}

{
public static void main(String[]arg)
{
int a=10000, b=30000, c=2000;

if(a>b && a>c)
System.out.println("a is the greatest number");
else if(b>c)
System.out.println("b is the greatest number");
else
System.out.println("c is the greatest number");
}
}

8. import java.util.Scanner;
class YesNoCancleusingifelse
{
public static void main(String[]arg)
{
Scanner sc=new Scanner(System.in);
System.out.println("enter the value");
char ch=sc.next().charAt(0);
if(ch=='y')
System.out.println("yes");
else if(ch=='n')
System.out.println("no");
else if(ch=='c')
System.out.println("cancle");
else
System.out.println("other");
}
}

9. import java.util.Scanner;
class Check1digit2digit3digitndabove3digitnumber
{
public static void main(String[]arg)
{
Scanner sc=new Scanner(System.in);
System.out.println("enter digits...");
int num=sc.nextInt();

if(num<=9)
{
System.out.println("1");
}
else if(num<=99)
{
System.out.println("2");
}
else if(num<=999)
{
System.out.println("3");
}
else
{
System.out.println("above 3 digit");
}
}
}

10. class Marksheet
{
public static void main(String[]arg)
{
int m1=29, m2=86, m3=80, m4=89, m5=66;

if((m1>=0&&m1<=100)&&(m2>=0&&m2<=100)&&(m3>=0&&m3<=100)&&(m4>=0&&m4<=100)&&(m5>=0&&m5<=100))
{

int c=0;
int mark=0;
String sub="";
String dist="";

if(m1>=75)
{
dist +="physics";
}

if(m2>=75)
{
dist +="chemistry";
}

if(m3>=75)
{
dist +="maths";
}

if(m4>=75)
{
dist +="english";
}

if(m5>=75)
{
dist +="hindi";
}

if(m1<33)
{
sub +="physics";
c++;
mark=m1;
}
if(m2<33)
{
sub +="chemistry";
c++;
mark=m2;
}
if(m3<33)
{
sub +="maths";
c++;
mark=m3;
}
if(m4<33)
{
sub +="english";
c++;
mark=m4;
}
if(m5<33)
{
sub +="hindi";
c++;
mark=m5;
}

if(c==0 || (c==1&& mark>=28))
{
float per=(m1+m2+m3+m4+m5)/5;

if(per>33&&per<45)
System.out.println("pass with third division");
else if(per<60)
System.out.println("pass with second division");
else
System.out.println("pass with first division");

if(c==1)
System.out.println("pass by grace with" +5+"grace sub name is" +sub);

if(dist!="")
System.out.println("distinction subject name is" +dist);
}
else if(c==1)
{
System.out.println("try again you are suppl in" +sub);
}
else
{
System.out.println("sorry you have failed in "+sub);
}
}
else
{
System.out.println("entered sub mark should be 0 to 100");
}
}
}

11. //WAP to increase the salary of employees from 500, if the salary is less than 10000 otherwise the same salaries will print

class Salary
{
public static void main(String[]args)
{
int s=9999;
if(s<10000);
s= s+500;
System.out.println(s);
}
}

12. // WAP to pass student by grace if entered subject mark is >28 otherwise same mark

import java.util.Scanner;
class Grace
{
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
System.out.println("Enter number");
int m, g;
m=sc.nextInt();
if(m>=28 && m<33);
{
g=33-m;
m=g+m;
System.out.println("gracenumber" +g);
}
System.out.println("marksobtain" +m);
}
}

13. //WAP to calculate square if the number is odd and calculate the cube if the number is even

class Calcubs
{
public static void main(String[]args)
{
int a=9;
if(a%2==0)
System.out.println("cube");
else
System.out.println("square");
}
}

14. import java.util.Scanner;
class Oec
{
public static void main(String[]args)
{
Scanner sc= new Scanner(System.in);
System.out.println("enter number");
int num=sc.nextInt();

if(num%2==0)
{
System.out.println("square");
}
else
{
System.out.println("cube");
}
}
}

15. class Marksheets
{
public static void main(String[]args)
{
int s1=27, s2=88, s3=65, s4=55, s5=29;

if (s1>=28 && s1<33)
{
System.out.println("pass with grace");
}
if (s1>33)
{
System.out.println( "pass" +s1);
}

else
{
System.out.println("fail" +s1);
}
if (s2>=28 && s2<33)
{
System.out.println("pass with grace");
}
if (s2>33)
{
System.out.println( "pass" +s2);
}

else
{
System.out.println("fail" +s2);
}
if (s3>=28 && s3<33)
{
System.out.println("pass with grace");
}
if (s3>33)
{
System.out.println( "pass" +s3);
}

else
{
System.out.println("fail" +s3);
}
if (s4>=28 && s4<33)
{
System.out.println("pass with grace");
}
if (s4>33)
{
System.out.println("pass" +s4);
}

else
{
System.out.println("fail" +s4);
}
if (s5>=28 && s5<33)
{
System.out.println("pass with grace");
}
if (s5>33)
{
System.out.println("pass" +s5);

}
else
{
System.out.println("fail" +s5);
}
if (s1>=33 && s2>=33 && s3>=33 && s4>=33 && s5>=33)
{
System.out.println("final result pass");
}
else
{
System.out.println("final result fail");
}
int t;
t=s1+s2+s3+s4+s5;
System.out.println("total=" +t +"/500");

float per= t/5;
System.out.println("percent=" +per);
}
}

16. class Marks
{
public static void main(String[]args)
{
int s1=27, s2=88, s3=65, s4=55, s5=29, g;

if (s1>=28 && s1<33)
{
g=33-s1;
s1=g+s1;
System.out.println("pass with grace");
}
if (s1>33)
{
System.out.println( "pass" +s1);
}
else
{
System.out.println("fail" +s1);
}

if (s2>=28 && s2<33)
{
g=33-s2;
s2=g+s2;
System.out.println("pass with grace");
}
if (s2>33)
{
System.out.println( "pass" +s2);
}

else
{
System.out.println("fail" +s2);
}
if (s3>=28 && s3<33)
{
g=33-s3;
s3=g+s3;
System.out.println("pass with grace");
}
if (s3>33)
{
System.out.println( "pass" +s3);
}

else
{
System.out.println("fail" +s3);
}
if (s4>=28 && s4<33)
{
g=33-s4;
s4=g+s4;
System.out.println("pass with grace");
}
if (s4>33)
{
System.out.println("pass" +s4);
}

else
{
System.out.println("fail" +s4);
}
if (s5>=28 && s5<33)
{
g=33-s5;
s5=g+s5;
System.out.println("pass with grace");
}
if (s5>33)
{
System.out.println("pass" +s5);

}
else
{
System.out.println("fail" +s5);
}
if (s1>=33 && s2>=33 && s3>=33 && s4>=33 && s5>=33)
{
System.out.println("final result pass");
}
else
{
System.out.println("final result fail");
}
int t;
t=s1+s2+s3+s4+s5;
System.out.println("total=" +t +"/500");

float per= t/5;
System.out.println("percent=" +per);
}
}

17. import java.util.*;
class IF
{
public static void main(String arg[])
{
int x=500;

Scanner sc=new Scanner(System.in);
System.out.println("ENter salary");
float salary=sc.nextInt();
if(salary<=10000)
{
salary=salary+x;
}
System.out.println(salary);
}
}

18. import java.util.*;
class Res
{
public static void main(String arg[])
{
Scanner sc=new Scanner(System.in);
System.out.println("enter marks");
float m=sc.nextInt();
if(m>=28 && m<=33)
{
m=m+5;
System.out.println("pass by grace" +m);
}
else
{
System.out.println(m);
}
}
}

19. import java.util.*;
class Od
{
public static void main(String arg[])
{
Scanner sc=new Scanner(System.in);
System.out.println("enter number");
int x=sc.nextInt();
if(x%2==0)
{
x=x*x;
}
if(x%2==1)
{
x=x*x*x;
}
System.out.println(x);
}
}

20. import java.util.*;
class Gr
{
public static void main(String arg[])
{

Scanner sc=new Scanner(System.in);
System.out.println("a=");
int a=sc.nextInt();
Scanner sd=new Scanner(System.in);
System.out.println("b=");
int b=sd.nextInt();
Scanner se=new Scanner(System.in);
System.out.println("c=");
int c=se.nextInt();
if(a>b &&a>c)
{
System.out.println("a is greatest");
}
if(b>a &&b>c)
{
System.out.println("b is greatest");
}
if(c>a &&c>b)
{
System.out.println("c is greatest");
}
}
}

21. import java.util.Scanner;
class salary
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the salary");
int x=sc.nextInt();
if(x<=1000)
{
x=x+500;

}
System.out.println(x);
}
}

22. import java.util.Scanner;
class grase
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the marks");
int x=sc.nextInt();
if(x>28&& x<33)
{
x=x+7;
System.out.println("pas by marks="+x);
}
else
{
System.out.println(x);
}
}
}

23. import java.util.Scanner;
class sum
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the number");
int num=sc.nextInt();
if(num%2==0)
{
num=num*num;
System.out.println("number is squre="+num);

}
else
{
System.out.println("number is not cude ="+num);
}

}
}

24. //WAP to check 1 digit, 2 digits,3 digits, and above 3 digit number?
import java.util.Scanner;
class NumberOfDigit
{
public static void main(String...args)
{
int num,rem;
short count=0;
Scanner sc=new Scanner (System.in);
num=sc.nextInt();
while(num!=0)
{
rem=num%10;
num/=10;
count++;
}
if(count==1)
System.out.println("This is "+count+" digit number");
if(count==2)
System.out.println("This is "+count+" digit number");
if(count==3)
System.out.println("This is "+count+" digit number");
if(count==4)
System.out.println("This is "+count+" digit number");
}

}

25. //WAP to find the middle number in three different numbers?
import java.util.Scanner;
class Middlenumber
{
public static void main (String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("enter a");
int a=sc.nextInt();
System.out.println("enter b");
int b=sc.nextInt();
System.out.println("enter c");
int c=sc.nextInt();
if(ab)if(aa)if( b>c){
System.out.println("c is middle number"+c);}
}
}

26. /WAP to check 1 digit, 2 digits,3 digits, and above 3 digit number?
import java.util.Scanner;
class Numberofdigit
{
public static void main (String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("enter num");
int num=sc.nextInt();
int count=0;
while(num!=0){
num=num/10;
count++;
}
if(count==1){
System.out.println("one digit num");
}
else if(count==2){
System.out.println("two digit num");
}
else if(count==3){
System.out.println("three digit num");}
else
System.out.println(" above three digit num");
}
}

27. // Wap to find the middle number in three diffrent Numbers

import java.util.*;
class Basic
{
static public void main(String ar[])
{
Scanner sc=new Scanner(System.in);
int x=sc.nextInt();
int y=sc.nextInt();
int z=sc.nextInt();
if(x>y)
{
if(x<z)
{
System.out.println("middle no is = "+x);
}
else
{
if(y>x)
{
if(y<z)
{
System.out.println("middle no is = "+x);
}
else
{
System.out.println("middle no is = "+z);
}

}
else
{
System.out.println("middle no is = "+z);
}
}
}
else
{
if(x<z)
{
if(z>y)
{
System.out.println("middle no is = "+y);
}
else{
System.out.println("middkle no is = "+z);
}
}
else
{
if(z>y)
{
System.out.println("middle no is = "+y);
}
else{
System.out.println("middle no is = "+x);
}
}

}

}
}

28. //WAP to find the middle number in three different numbers?
import java.util.Scanner;
class Middlenumber
{
public static void main (String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("enter a");
int a=sc.nextInt();
System.out.println("enter b");
int b=sc.nextInt();
System.out.println("enter c");
int c=sc.nextInt();
if(ab)if(aa)if( b>c){
System.out.println("c is middle number"+c);}
}
}

29. //
import java.util.*;
class FindMiddle

{

public static void main (String args[])
{

int num1,num2,num3;//variable declaration for three numbers

Scanner scan=new Scanner(System.in);
System.out.print("Enter the numbers: ");

num1=scan.nextInt();
num2=scan.nextInt();
num3=scan.nextInt();

if(num2>num1 && num1>num3 || num3>num1 && num1>num2){
System.out.print(num1+"is a middle number");
}

if(num1>num2 && num2>num3 || num3>num2 && num2>num1){
System.out.print(num2+"is a middle number");
}

if(num1>num3 && num3>num2 || num2>num3 && num3>num1){
System.out.print(num3+"is a middle number");
}
}
}

//
Enter the numbers: 23
56
12
23is a middle number

30. Wap grates among 4 no

// Abhishek chauhan

public class Largest {

public static void main(String[] args) {

double n1 = -4.5, n2 = 3.9, n3 = 2.5;

if( n1 >= n2 && n1 >= n3)
System.out.println(n1 + " is the largest number.");

else if (n2 >= n1 && n2 >= n3)
System.out.println(n2 + " is the largest number.");

else
System.out.println(n3 + " is the largest number.");
}
}

//output
3.9 is the largest number.

31. Akshay Jangde
class Findmiddle
{
public static void main(String[] args)
{
int a=105,b=12,c=100;
if(a>c && bc )

{

System.out.println("c is middle number");
}
else if(ab || a>b && a<c)
{
System.out.println("a is the middle number");
}
else
{
System.out.println("b is the middle number");
}

}
}

32. Akshay Jangde
import java.util.*;

class Checkyesorno
{
public static void main(String...args)
{
Scanner sc=new Scanner(System.in);
System.out.println("enter the character");
char c=sc.next().charAt(0);

if(c == 'y')
System.out.println("yes");
else if(c == 'n')
System.out.println("no");
else if(c == 'c')
System.out.println("cancel");

}
}

33. //WAP to display yes, no, and cancel when the user assigns y,n, and c?
class Display
{
public static void main(String args[])
{
char ch='y';
if(ch=='y')
{
System.out.println("Yes");
}
else if(ch=='n')
{
System.out.println("NO");
}
else if(ch=='c')
{
System.out.println("Cancel");
}
else
{
System.out.println("Other");
}
}
}

34. WAP to calculate the greatest number among 4 numbers
Program:
import java.util.Scanner;
class Main {
public static void main(String[] args) {
int a,b,c,d;
Scanner scan=new Scanner(System.in);
System.out.print("Enter 4 numbers - ");
a=scan.nextInt();
b=scan.nextInt();
c=scan.nextInt();
d=scan.nextInt();
if(a>b) {
if(a>c) {
if(a>d)
System.out.print(a+"is greatest");
else
System.out.print(d+"is greatest");
}
else {
if(c>d)
System.out.print(c+"is greatest");
else
System.out.print(d+"is greatest");
}
}
else {
if(b>c) {
if(b>d)
System.out.print(b+"is greatest");
else
System.out.print(d+"is greatest");

}
else {
if(c>d)
System.out.print(d+"is greatest");
else
System.out.print(d+"is greatest");
}
}
}
}

35. WAP to find the middle number in three different numbers?
Program:

import java.util.Scanner;
public class Main {

public static void main(String[] args) {
int a,b,c;
Scanner scan=new Scanner(System.in);
System.out.println("Enter three numbers - ");
a=scan.nextInt();
b=scan.nextInt();
c=scan.nextInt();
if(a>b) {
if(ac)
System.out.println(b+" is middle number");
else
System.out.println(c+" is middle number");
}
}
else {
if(b>a) {
if(bc)
System.out.println(a+" is middle number");
else
System.out.println(c+" is middle number");
}
}
}

}

}

36. WAP to check 1 digit, 2 digits,3 digits, and above 3 digit number?
Program:

import java.util.Scanner;
public class Main {

public static void main(String[] args) {
int num;
Scanner scan=new Scanner(System.in);
System.out.print("Enter a number - ");
num=scan.nextInt();
if(num<10) {
System.out.println(num+"is a single digit number.");
}
if(num<100) {
if(num>=10)
System.out.println(num+" is a two digit number.");
}
if(num>=100) {
if(num<1000)
System.out.println(num+" is a three digit number.");
else
System.out.println(num+" is above 3 digit number.");
}
}

}

37. //WAP to find the middle number in three different numbers?
import java.util.Scanner;
class Middlenumber
{
public static void main (String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("enter a");
int a=sc.nextInt();
System.out.println("enter b");
int b=sc.nextInt();
System.out.println("enter c");
int c=sc.nextInt();
if(ab)if(aa)if( b>c){
System.out.println("c is middle number"+c);}
}
}

38. // WAP to create a mark-sheet of Students using five different subjects with the following condition?

//1) All Subject Marks Should be 0 to 100.

//2) If only Subject Mark is <33 Then Student will Suppl

//3) If Minimum Two Subjects Marks is <33 Then Student Will Fail

//4) IF all Subject Marks is > 33 then percentage and division should be calculated.

//5) IF only one subject Mark is >28 and <33 then 5 grace marks will be applied and the student will be passing by grace.

//6) Display Grace Subject Name, Distinction Subject name, Supp Subject name, and Failed Subject name.
import java.util.Scanner;
class Marksheet
{
public static void main(String...args)
{
int p,c,m,e,pe;
double per;
Scanner sc=new Scanner(System.in);
System.out.println("Enter physics marks");
p=sc.nextInt();
System.out.println("Enter chemistry marks");
c=sc.nextInt();
System.out.println("Enter maths marks");
m=sc.nextInt();
System.out.println("Enter english marks");
e=sc.nextInt();
System.out.println("Enter physical education marks");
pe=sc.nextInt();
if((p>=0 && p<=100) && (c>=0 && c<=100) && (m>=0 && m<=100) && (e>=0 &&e<=100) && (pe>=0 && pe<=100))
{ String sub="";
short count=0;
if(p<33)
{
count++;
if(p>28 && p<33)
{
p=p+(p-33);
sub=sub+"physics";
}
}
if(c<33)
{
count++;
if(c>28 && c<33)
{
c=c+(c-33);
sub=sub+"chemistry";
}
}
if(m<33)
{
count++;
if(m>28 && m<33)
{
m=m+(p-33);
sub=sub+"maths";
}
}
if(e<33)
{
count++;
if(e>28 && e<33)
{
e=e+(e-33);
sub=sub+"english";
}
}
if(pe<33)
count++;
{
if(pe>28 && pe<33)
{
pe=pe+(pe-33);
sub=sub+"phsical eduaction";
}
}
if(count==0)
{
per=((p+c+m+e+pe)/500.00)*100.00;
if(per>33 && per<45)
System.out.println("Pass with "+per+" and got third division");
else if(per>45 && per<60)
System.out.println("Pass with "+per+" and got second division");
else
System.out.println("Pass with "+per+" and got first division");
if(p>=75)
System.out.println("got Distinction in physics");
if(c>=75)
System.out.println("got Distinction in chemistry");
if(m>=75)
System.out.println("got Distinction in maths");
if(e>=75)
System.out.println("got Distinction in english");
if(pe>=75)
System.out.println("got Distinction in physical education");
}
else if(count==1)
System.out.println("passed with grace in "+sub);
else
System.out.println("fail to clear exam");
}
}
}

39. // WAP to create a mark-sheet of Students using five different subjects with the following condition?

//1) All Subject Marks Should be 0 to 100.

//2) If only Subject Mark is <33 Then Student will Suppl

//3) If Minimum Two Subjects Marks is <33 Then Student Will Fail

//4) IF all Subject Marks is > 33 then percentage and division should be calculated.

//5) IF only one subject Mark is >28 and <33 then 5 grace marks will be applied and the student will be passing by grace.

//6) Display Grace Subject Name, Distinction Subject name, Supp Subject name, and Failed Subject name.
import java.util.Scanner;
class Marksheet
{
public static void main(String...args)
{
int p,c,m,e,pe;
double per;
Scanner sc=new Scanner(System.in);
System.out.println("Enter physics marks");
p=sc.nextInt();
System.out.println("Enter chemistry marks");
c=sc.nextInt();
System.out.println("Enter maths marks");
m=sc.nextInt();
System.out.println("Enter english marks");
e=sc.nextInt();
System.out.println("Enter physical education marks");
pe=sc.nextInt();
if((p>=0 && p<=100) && (c>=0 && c<=100) && (m>=0 && m<=100) && (e>=0 &&e<=100) && (pe>=0 && pe<=100))
{ String sub="";
short count=0;
if(p<33)
{
count++;
if(p>28 && p<33)
{
p=p+(p-33);
sub=sub+"physics";
}
}
if(c<33)
{
count++;
if(c>28 && c<33)
{
c=c+(c-33);
sub=sub+"chemistry";
}
}
if(m<33)
{
count++;
if(m>28 && m<33)
{
m=m+(p-33);
sub=sub+"maths";
}
}
if(e<33)
{
count++;
if(e>28 && e<33)
{
e=e+(e-33);
sub=sub+"english";
}
}
if(pe<33)
count++;
{
if(pe>28 && pe<33)
{
pe=pe+(pe-33);
sub=sub+"phsical eduaction";
}
}
if(count==0)
{
per=((p+c+m+e+pe)/500.00)*100.00;
if(per>33 && per<45)
System.out.println("Pass with "+per+" and got third division");
else if(per>45 && per<60)
System.out.println("Pass with "+per+" and got second division");
else
System.out.println("Pass with "+per+" and got first division");
if(p>=75)
System.out.println("got Distinction in physics");
if(c>=75)
System.out.println("got Distinction in chemistry");
if(m>=75)
System.out.println("got Distinction in maths");
if(e>=75)
System.out.println("got Distinction in english");
if(pe>=75)
System.out.println("got Distinction in physical education");
}
else if(count==1)
System.out.println("passed with grace in "+sub);
else
System.out.println("fail to clear exam");
}
}
}

40. // WAP to create a mark-sheet of Students using five different subjects with the following condition?

//1) All Subject Marks Should be 0 to 100.

//2) If only Subject Mark is <33 Then Student will Suppl

//3) If Minimum Two Subjects Marks is <33 Then Student Will Fail

//4) IF all Subject Marks is > 33 then percentage and division should be calculated.

//5) IF only one subject Mark is >28 and <33 then 5 grace marks will be applied and the student will be passing by grace.

//6) Display Grace Subject Name, Distinction Subject name, Supp Subject name, and Failed Subject name.
import java.util.Scanner;
class Marksheet
{
public static void main(String...args)
{
int p,c,m,e,pe;
double per;
Scanner sc=new Scanner(System.in);
System.out.println("Enter physics marks");
p=sc.nextInt();
System.out.println("Enter chemistry marks");
c=sc.nextInt();
System.out.println("Enter maths marks");
m=sc.nextInt();
System.out.println("Enter english marks");
e=sc.nextInt();
System.out.println("Enter physical education marks");
pe=sc.nextInt();
if((p>=0 && p<=100) && (c>=0 && c<=100) && (m>=0 && m<=100) && (e>=0 &&e<=100) && (pe>=0 && pe<=100))
{ String sub="";
short count=0;
if(p<33)
{
count++;
if(p>28 && p<33)
{
p=p+(p-33);
sub=sub+"physics";
}
}
if(c<33)
{
count++;
if(c>28 && c<33)
{
c=c+(c-33);
sub=sub+"chemistry";
}
}
if(m<33)
{
count++;
if(m>28 && m<33)
{
m=m+(p-33);
sub=sub+"maths";
}
}
if(e<33)
{
count++;
if(e>28 && e<33)
{
e=e+(e-33);
sub=sub+"english";
}
}
if(pe<33)
count++;
{
if(pe>28 && pe<33)
{
pe=pe+(pe-33);
sub=sub+"phsical eduaction";
}
}
if(count==0)
{
per=((p+c+m+e+pe)/500.00)*100.00;
if(per>33 && per<45)
System.out.println("Pass with "+per+" and got third division");
else if(per>45 && per<60)
System.out.println("Pass with "+per+" and got second division");
else
System.out.println("Pass with "+per+" and got first division");
if(p>=75)
System.out.println("got Distinction in physics");
if(c>=75)
System.out.println("got Distinction in chemistry");
if(m>=75)
System.out.println("got Distinction in maths");
if(e>=75)
System.out.println("got Distinction in english");
if(pe>=75)
System.out.println("got Distinction in physical education");
}
else if(count==1)
System.out.println("passed with grace in "+sub);
else
System.out.println("fail to clear exam");
}
}
}

// WAP to create a mark-sheet of Students using five different subjects with the following condition

import java.util.*;
class Done
{
public static void main(String ar[])
{
Scanner sc=new Scanner(System.in);

int maths=sc.nextInt();
int phy=sc.nextInt();
int che=sc.nextInt();
int hindi=sc.nextInt();
int eng=sc.nextInt();
int check=0;
String call="";

if((maths>=0 && maths<=100)&&(phy>=0 && phy<=100)&&(che>=0 && che<=100)&&(hindi>=0 && hindi<=100)&&(eng>=0 && eng<=100))
{
if( (maths>=28 && maths<33) )
{
int Grace=33-maths;
maths+=Grace;
System.out.println("Grace Subject name is= Maths");

}
if( (phy>=28 && phy<33) )
{
int Grace=33-phy;
phy+=Grace;
System.out.println("Grace Subject name is= Physics");

}
if( (che>=28 && che<33) )
{
int Grace=33-che;
che+=Grace;
System.out.println("Grace Subject name is= Chemistry");

}
if( (hindi>=28 && hindi<33) )
{
int Grace=33-hindi;
hindi+=Grace;
System.out.println("Grace Subject name is= Hindi");
}
if( (eng>=28 && eng<33) )
{
int Grace=33-eng;
eng+=Grace;
System.out.println("Grace Subject name is= English");
}
if(maths<28)
{
check++;
call+="Maths";
}
if(phy<28)
{
check++;
call+="Physics"+" ";
}
if(che<28)
{
check++;
call+="Chemistry"+" ";
}
if(hindi<28)
{
check++;
call+="Hindi"+" ";
}
if(eng<28)
{
check++;
call+="English"+" ";
}
if(phy<33||maths<33||che<33||hindi<33||eng<33)
{
if(check==1)
{
System.out.println("Supplymentry subject is="+call);

}
else
{
System.out.println("Fail subjects are="+call);
}
}
if(phy>33 && maths>33 && che>33 && hindi>33 && eng>33)
{
float percentage=(float)(maths+phy+che+hindi+eng)/5;
System.out.println("Percentage= "+percentage);
if(percentage>33 && percentage<45)
{
System.out.println("Third Division");
}
else if(percentage>45 && percentage<60)
{
System.out.println("Second Division");
}
else
{
System.out.println("first Division");
}
}
}

}
}

// WAP to create a mark-sheet of Students using five different subjects with the following condition

import java.util.*;
class Done
{
public static void main(String ar[])
{
Scanner sc=new Scanner(System.in);

int maths=sc.nextInt();
int phy=sc.nextInt();
int che=sc.nextInt();
int hindi=sc.nextInt();
int eng=sc.nextInt();
int check=0;
String call="";

if((maths>=0 && maths<=100)&&(phy>=0 && phy<=100)&&(che>=0 && che<=100)&&(hindi>=0 && hindi<=100)&&(eng>=0 && eng<=100))
{
if( (maths>=28 && maths<33) )
{
int Grace=33-maths;
maths+=Grace;
System.out.println("Grace Subject name is= Maths");

}
if( (phy>=28 && phy<33) )
{
int Grace=33-phy;
phy+=Grace;
System.out.println("Grace Subject name is= Physics");

}
if( (che>=28 && che<33) )
{
int Grace=33-che;
che+=Grace;
System.out.println("Grace Subject name is= Chemistry");

}
if( (hindi>=28 && hindi<33) )
{
int Grace=33-hindi;
hindi+=Grace;
System.out.println("Grace Subject name is= Hindi");
}
if( (eng>=28 && eng<33) )
{
int Grace=33-eng;
eng+=Grace;
System.out.println("Grace Subject name is= English");
}
if(maths<28)
{
check++;
call+="Maths";
}
if(phy<28)
{
check++;
call+="Physics"+" ";
}
if(che<28)
{
check++;
call+="Chemistry"+" ";
}
if(hindi<28)
{
check++;
call+="Hindi"+" ";
}
if(eng<28)
{
check++;
call+="English"+" ";
}
if(phy<33||maths<33||che<33||hindi<33||eng<33)
{
if(check==1)
{
System.out.println("Supplymentry subject is="+call);

}
else
{
System.out.println("Fail subjects are="+call);
}
}
if(phy>33 && maths>33 && che>33 && hindi>33 && eng>33)
{
float percentage=(float)(maths+phy+che+hindi+eng)/5;
System.out.println("Percentage= "+percentage);
if(percentage>33 && percentage<45)
{
System.out.println("Third Division");
}
else if(percentage>45 && percentage<60)
{
System.out.println("Second Division");
}
else
{
System.out.println("first Division");
}
}
}

}
}

// WAP to create a mark-sheet of Students using five different subjects with the following condition

import java.util.*;
class Done
{
public static void main(String ar[])
{
Scanner sc=new Scanner(System.in);

int maths=sc.nextInt();
int phy=sc.nextInt();
int che=sc.nextInt();
int hindi=sc.nextInt();
int eng=sc.nextInt();
int check=0;
String call="";

if((maths>=0 && maths<=100)&&(phy>=0 && phy<=100)&&(che>=0 && che<=100)&&(hindi>=0 && hindi<=100)&&(eng>=0 && eng<=100))
{
if( (maths>=28 && maths<33) )
{
int Grace=33-maths;
maths+=Grace;
System.out.println("Grace Subject name is= Maths");

}
if( (phy>=28 && phy<33) )
{
int Grace=33-phy;
phy+=Grace;
System.out.println("Grace Subject name is= Physics");

}
if( (che>=28 && che<33) )
{
int Grace=33-che;
che+=Grace;
System.out.println("Grace Subject name is= Chemistry");

}
if( (hindi>=28 && hindi<33) )
{
int Grace=33-hindi;
hindi+=Grace;
System.out.println("Grace Subject name is= Hindi");
}
if( (eng>=28 && eng<33) )
{
int Grace=33-eng;
eng+=Grace;
System.out.println("Grace Subject name is= English");
}
if(maths<28)
{
check++;
call+="Maths";
}
if(phy<28)
{
check++;
call+="Physics"+" ";
}
if(che<28)
{
check++;
call+="Chemistry"+" ";
}
if(hindi<28)
{
check++;
call+="Hindi"+" ";
}
if(eng<28)
{
check++;
call+="English"+" ";
}
if(phy<33||maths<33||che<33||hindi<33||eng<33)
{
if(check==1)
{
System.out.println("Supplymentry subject is="+call);

}
else
{
System.out.println("Fail subjects are="+call);
}
}
if(phy>33 && maths>33 && che>33 && hindi>33 && eng>33)
{
float percentage=(float)(maths+phy+che+hindi+eng)/5;
System.out.println("Percentage= "+percentage);
if(percentage>33 && percentage<45)
{
System.out.println("Third Division");
}
else if(percentage>45 && percentage<60)
{
System.out.println("Second Division");
}
else
{
System.out.println("first Division");
}
}
}
else
{
System.out.println("your marks are not between 0-100");
}

}
}

44. import java.util.Scanner;
class MarkSheet
{
public static void main (String args[])
{
Scanner sc=new Scanner(System.in);
double maths,physics,eng,hindi,bio;
double percentage=0;
System.out.println("Enter maths marks");
maths=sc.nextInt();
System.out.println("Enter physics marks");
physics=sc.nextInt();
System.out.println("Enter eng marks");
eng=sc.nextInt();
System.out.println("Enter hindi marks");
hindi=sc.nextInt();
System.out.println("Enter bio marks");
bio=sc.nextInt();
if((maths>0&&maths<100)||(physics>0&&physics<100)||(eng>0&&eng<100)||(hindi>0&&hindi<100)||(bio>0&&bio<100))
{
if(maths<33 ||physics<33 ||eng<33 || hindi<33 || bio<33){
if(maths<33)
if(physics<33 ||eng<33 || hindi<33 || bio<33)
System.out.println("Student is fail");
else{System.out.println("Got supplementary in maths");
if(maths>28 && maths<33){maths+=5;System.out.println("pass by grace in maths"+maths);}
}

else if(physics<33)
if(maths<33 ||eng<33 || hindi<33 || bio<33) System.out.println("Student is fail");
else{System.out.println("Got supplementary in physics");
if(physics>28 && physics<33){physics+=5;System.out.println("pass by grace in physics"+physics);}}

else if(eng<33)
if(maths<33 || physics<33 || hindi<33 || bio<33) System.out.println("Student is fail");
else {System.out.println("Got supplementary in english");
if(eng>28 && eng<33){eng+=5;System.out.println("pass by grace in english"+eng);}}

else if(hindi<33)
if(maths<33 ||eng<33 || physics<33 || bio<33) System.out.println("Student is fail");
else {System.out.println("Got supplementary in hindi");
if(hindi>28 && hindi<33){hindi+=5;System.out.println("pass by grace in hindi"+hindi);}}

else if(bio<33)
if(maths<33 ||eng<33 || hindi<33 || physics<33) System.out.println("Student is fail");
else {System.out.println("Got supplementary in bio");
if(bio>28 && maths<33){bio+=5;System.out.println("pass by grace in bio"+bio);}}
}
else{
percentage=(((maths+eng+physics+hindi+bio)/500)*100);
System.out.println("Percentage="+percentage);
if(percentage>=60 && percentage<=75)System.out.println("1st division");
else if(percentage>=50 && percentage<60)System.out.println("2nd division");
else if(percentage>=40 && percentage<50)System.out.println("3rd division");
}
if(maths>=75)System.out.println("Got distinction in maths");
if(physics>=75)System.out.println("Got distinction in physics");
if(eng>=75)System.out.println("Got distinction in english");
if(hindi>=75)System.out.println("Got distinction in hindi");
if(bio>=75)System.out.println("Got distinction in bio");
}
}
}

45. //WAP to check divisibility of numbers that number is divisible by 3,5 and 9 with all combinations?
class Divisibility
{

public static void main(String arg[])
{
int num=45;
if(num%3==0)
System.out.println(num+"is divisible by 3");
if(num%5==0)
System.out.println(num+"is divisible by 5");
if(num%9==0)
System.out.println(num+"is divisible by 9");

}
}

46. WAP to create a mark-sheet of Students using five different subjects
Program:

import java.util.Scanner;

public class Report_card {

public static void main(String[] args) {
int count=0,temp=0;
float percentage;
String dist=" ";
String grace_sub=" ";
String fail=" ";
int maths,phy,chem,hindi,eng;
// Input by user
Scanner scan=new Scanner(System.in);
System.out.print("Enter marks of \nMaths - ");
maths=scan.nextInt();
if(maths>100) {
System.out.print("Enter valid marks- ");
maths=scan.nextInt();
}
System.out.print("Physics - ");
phy=scan.nextInt();
if(phy>100) {
System.out.print("Enter valid marks- ");
phy=scan.nextInt();
}
System.out.print("Chemistry - ");
chem=scan.nextInt();
if(chem>100) {
System.out.print("Enter valid marks- ");
chem=scan.nextInt();
}
System.out.print("Hindi - ");
hindi=scan.nextInt();
if(hindi>100) {
System.out.print("Enter valid marks- ");
hindi=scan.nextInt();
}
System.out.print("English - ");
eng=scan.nextInt();
if(eng>100) {
System.out.print("Enter valid marks- ");
eng=scan.nextInt();
}
// Calculations
if(maths>=75)
dist=dist+"Maths ";
if(phy>=75)
dist=dist+"Physics ";
if(chem>=75)
dist=dist+"Chemistry ";
if(hindi>=75)
dist=dist+"Hindi ";
if(eng>=75)
dist=dist+"English ";
if(maths<33) {
count++;
grace_sub="Maths";
temp=maths;
maths=maths+5;
fail=fail+"Maths ";
}
if(phy<33) {
count++;
grace_sub="Physics";
temp=phy;
phy=phy+5;
fail=fail+"Physics ";
}
if(chem<33) {
count++;
grace_sub="Chemistry";
temp=chem;
chem=chem+5;
fail=fail+"Chemistry ";
}
if(hindi<33) {
count++;
grace_sub="Hindi";
temp=hindi;
hindi=hindi+5;
fail=fail+"Hindi ";
}
if(eng<33) {
count++;
grace_sub="English";
temp=eng;
eng=eng+5;
fail=fail+"English ";
}
/// OUTPUT RESULT
System.out.println("__RESULT______________");
if(count==0||(count==1&&temp>=28)) {
if(count==1)
System.out.println("\nPassed by grace. Grace subject "+grace_sub);
System.out.println("Distinction in subjects- "+dist);
percentage=(maths+phy+chem+hindi+eng)/5;
if(percentage<45)
System.out.println("Percentage = "+percentage+" \nThird division");
else if(percentage<60)
System.out.println("Percentage = "+percentage+" \nSecond division");
else
System.out.println("Percentage = "+percentage+" \nFirst division");

}
else if(count==1&&temp<28)
System.out.println("Supplementry in subject- "+grace_sub+" marks- "+(temp-5));
else if(count>1)
System.out.println("Fail! in "+count+" subjects- "+fail);

}

}

47. //Q1) WAP to display yes, no, and cancel when the user assigns y,n, and c using ladder if else?
class Display
{
public static void main(String[] args) {

char ch='C';
if(ch=='y'|| ch=='Y')
System.out.println("yes");
else if(ch=='n'|| ch=='N')
System.out.println("No");
else if(ch=='c' || ch=='C')
System.out.println("Cancel");
else
System.out.println("Wrong input");

}
}

48. import java.util.Scanner;
class Squ
{
public static void main(String args[])
{
int num;
Scanner sc=new Scanner(System.in);
System.out.println("enter number");
num=sc.nextInt();
if(num%2==0)
{
num=num*num;
System.out.println("given num is even and num of square is" +num);
}
else
{
num=num*num*num;
System.out.println("given num is odd and num of cube is" +num);

}
}
}

49. //Q) WAP to check 1 digit, 2 digits,3 digits, and above 3 digit number?

class DigitChecker
{
public static void main(String[] args) {

int num=10000;
if(num>=1 && num<10)
System.out.println(num+"is one digit no");
else if(num>=10 && num<100)
System.out.println(num+"is two digit no");
else if(num>=100 && num<1000)
System.out.println(num+"is three digit no");
else
System.out.println(num+" above three digit no");

}
}

50. // WAP to check the greatest number
import java.util.Scanner;
class Greatest1
{
public static void main(String abc[])
{
int x,y,z;
Scanner sc= new Scanner(System.in);
System.out.println("enter number");
x=sc.nextInt();
y=sc.nextInt();
z=sc.nextInt();
if (x>y)
{
if(x>z)
System.out.println("the greatest number is" +x);
else
System.out.println("he greatest number is" +z);
}
else if(y>z)
{
if(z>x)
System.out.println("he greatest number is" +z);
else
System.out.println("he greatest number is" +y);
}

}
}

51. -WAP to check 1 digit, 2 digits,3 digits, and above 3 digit number?

import java.util.Scanner;
class Digit
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter number");
int num=sc.nextInt();

if(num>=0 && num<10)
System.out.println("One digit no.");

else if(num>=10 && num<100)
System.out.println("Two digit no.");

else if(num>=100 && num<1000)
System.out.println("Three digit no.");

else
System.out.println("More than three digit no.");
}
}

52. Khushboo Sendre

import java.util.Scanner;
class Covid
{
public static void main(String args[])
{
System.out.println("Enter covid result");

if(new Scanner(System.in).next().equals("positive"))
{
System.out.println("You are quarantine for 15 days");
}
}
}

53. Khushboo Sendre

class Salary
{
public static void main(String args[])
{
int salary = 8000;

if(salary<10000)
salary = salary+500;
System.out.println(salary);
}
}

54. Khushboo Sendre

import java.util.Scanner;
class MarksCalculate
{
public static void main(String...args)
{
Scanner sc = new Scanner(System.in);
int marks,grace;
System.out.println("Enter the number");
marks = sc.nextInt();

if(marks>=28&&marks<33)
{
grace = 33-marks;
marks = marks+grace;
System.out.println("Grace mark=" +grace);
}
System.out.println("mark=" +marks);
}
}

55. Khushboo Sendre

class SquareCube
{
public static void main(String...args)
{
int num=2;
int res=0;

if(num%2==0)
res = num*num*num;
else
res = num*num;
System.out.println(res);
}
}

56. Khushboo Sendre

class Marksheet
{
public static void main(String args[])
{
int m1=95,m2=75,m3=67,m4=37,m5=29;
String s1="phy",s2="chem",s3="maths",s4="english",s5="hindi";
float per;
String sub="";
String dist="";
if((m1>=0 && m1<=100) && (m2>=0 && m2<=100) && (m3>=0 && m3<=100) &&(m4>=0 && m4<=100) && (m5>=0 && m5<=100))
{
int c=0;
int g=0;
if(m1<33)
{
g=m1;
sub=sub+s1+" ";
c++;
}
if(m2<33)
{
c++;
g=m2;
sub=sub+s2+" ";
}
if(m3<33)
{
g=m3;
c++;
sub=sub+s3+" ";
}
if(m4<33)
{
g=m4;
c++;
sub=sub+s4+" ";
}
if(m5<33)
{
g=m5;
c++;
sub=sub+s5+" ";
}
if(m1>=75)
dist = dist +s1 + " ";
if(m2>=75)
dist = dist +s2 + " ";
if(m3>=75)
dist = dist +s3+ " ";
if(m4>=75)
dist = dist +s4 + " ";
if(m5>=75)
dist = dist +s5 + " ";
if(c==0 || (c==1 && g>=28))
{
per=(m1+m2+m3+m4+m5)/5;
if(per>=33 && per<45)
System.out.println("Third division " + per + "%");
else if(per<60)
System.out.println("Second division " + per + "%");
else
System.out.println("First division " + per + "%");
if(g>0)
System.out.println("Pass by grace and grace mark is " +(33-g)+ "grace subject is "+sub);
if(dist!="")
System.out.println("Distinction Subject name is "+dist);
}
else if(c==1)
{
System.out.println("suppl subjects is "+sub);
}
else
{
System.out.println("fail subjects is "+sub);
}
}
else
{
System.out.println("Subject marks should be 0 to 100");
}
}
}

57. WAP to check vowel and consonent using nested if--else
class CheckVowelCons
{

public static void main(String args[])
{
char ch='b';
if(ch=='a')
System.out.println("vowel");
else
{
if(ch=='e')
System.out.println("vowel");

else
{
if(ch=='i')
System.out.println("vowel");

else
{
if(ch=='o')
System.out.println("vowel");
else
{
if(ch=='u')
System.out.println("vowel");
else
System.out.println("consonent");

}

}

}
}
}
}

58. WAP to display YES. NO and Cancel?

import java.util.Scanner;
class CheckYesNO
{

public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter char");
char ch=sc.next().charAt(0);
if(ch=='y')
System.out.println("yes");
else
{
if(ch=='n')
System.out.println("no");

else
{
if(ch=='c')
System.out.println("cancel");
else
System.out.println("cancel");

}
}
}
}

59. WAP to check even Number and odd Number Without using else Statement?
import java.util.Scanner;
class Evenodd
{
public static void main (String args[])
{
System.out.println("enter a number");
Scanner sc=new Scanner(System.in);
int num=sc.nextInt();
if(num%2==0)
{
System.out.println("this is even no");
}
else
{
System.out.println("this is odd no");
}
}
}

60. Ankita Verma

class Marksheet
{
public static void main(String args[])
{
int m1=75,m2=32,m3=67,m4=57,m5=87;
if((m1>=0 && m1<=100)&&(m2>=0 && m2<=100)&&(m3>=0 && m3<=100)
&&(m4>=0 && m4<=100)&&(m5>=0 && m5<=100))
{
int a=0;
int marks=0;
String dist="";
String sub="";

if(m1>=75)
{
dist+="Physics";
}
if(m2>=75)
{
dist+="Chemistry";
}
if(m3>=75)
{
dist+="Maths";
}
if(m4>=75)
{
dist+="English";
}
if(m5>=75)
{
dist+="Hindi";
}
if(m1<33)
{
sub+="Physics";
a++;
marks=m1;
}
if(m2<33)
{
sub+="Chemistry";
a++;
marks=m2;
}
if(m3<33)
{
sub+="Maths";
a++;
marks=m3;
}
if(m4<33)
{
sub+="English";
a++;
marks=m4;
}
if(m5<33)
{
sub+="Hindi";
a++;
marks=m5;
}
if(a==0||(a==1&&marks>=28))
{
float per=(m1+m2+m3+m4+m5)/5;
if(per>33&&per<45)
System.out.println("Pass with Third Division");
else if(per>45 && per<60)
System.out.println("Pass with Second Division");
else
System.out.println("Pass with First Division");
if(a==1)
System.out.println("Pass by grace with"+(33-28)+"Grace Subject name is " +sub);
if(dist!="")
System.out.println("Distinction Subject name is" +dist);
}
else if(a==1)
{
System.out.println("Try again you are suppl in" +sub);
}
else
{
System.out.println("Enter subject marks should be 0 to 100");
}
}
}
}

61. Ankita Verma

class Max
{
public static void main(String args[])
{
int x=457;
int a=x%10;
x=x/10;
int b=x%10;
x=x/10;
int c=x%10;
x=x/10;

int max=0;
if(max<a)
{
max=a;

System.out.println(max);
}
}
}

62. Ankita Verma

class Middle
{
public static void main(String args[])
{
int x=457;
x=x/10;
int a=x%10;

System.out.println(a);
}
}

63. Ankita Verma

class Middle
{
public static void main(String args[])
{
int x=457;
x=x/10;
int a=x%10;

System.out.println(a);
}
}

64. import java.util.Scanner;
public class CheckYesNoCancel {

public static void main(String[] args) {
char ch;
Scanner sc= new Scanner(System .in);
System.out.println("Enter char ");
ch=sc.next().charAt(0);

if (ch=='y')
{
System.out.println("Yes");

}

else
{
if(ch=='n')
{
System.out.println("No");
}
else
{
if(ch=='c')
{
System.out.println("Cancel");

}

else
System.out.println("other");
}
sc.close();
}
}

}

65. package checknumber;
import java.util.Scanner;
public class Middlenumber {

public static void main(String[] args) {
int x,y,z;
Scanner sc=new Scanner (System.in);
System.out.println("Enter 1st number");
x=sc.nextInt();
System.out.println("Enter 2nd number");
y=sc.nextInt();
System.out.println("Enter 3rd number");
z=sc.nextInt();

if(x>y && xz )
{
System.out.println("middle number ="+x);
}
else { if(y>x && yz)
{
System.out.println("middle number ="+y);
}
else
{
System.out.println("middle number =" +z);
}
}

}

}

66. package numberdigitcheck;
import java.util.Scanner;
public class NumberDigitCheck {

public static void main(String[] args) {
int num;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the number");
num=sc.nextInt();

if(num<10)
{System.out.println("Number is 1 digit");
}

else {
if(num>=10 && num<100)
{
System.out.println("Number is 2 digit");

}
else
{if(num>=100 && num<1000)
{System.out.println("Number is 3 digit");

}
else
{System.out.println("Number is more than 3 digit");

}
}
sc.close();
}
}

}

67. //yogesh seroke
//salary
import java.util.Scanner;
class salaryofEmploy
{
public static void main(String[]arg)
{
Scanner sc=new Scanner(System.in);
System.out.println("salary of employ");
int salary=sc.nextInt();

if(salary<10000)
salary=salary+500;
System.out.println(salary);
}
}

68. //yogesh seroke
//odd even
import java.util.Scanner;
class ODDEVEN
{
public static void main(String[]arg)
{
Scanner sc=new Scanner(System.in);
System.out.println("enter number...");
int num=sc.nextInt();

if(num%2==0)
{
num=num*num*num;
System.out.println(num);
}
else
{
num=num*num;
System.out.println(num);
}
}
}

69. //yogesh seroke
// greatest num
class Greatestnoabc
{
public static void main(String[]arg)
{
int a=2, b=8, c=34;

if(a>b)
{
if(a>c)
{
System.out.println("a is greater");
}
else
{
System.out.println("c is greater");
}
}
else
{
if(b>c)
{
System.out.println("b is greater");
}
else
{
System.out.println("c is greater");
}
}
}
}

70. //yogesh seroke
{
public static void main(String[]arg)
{
int a=10000, b=30000, c=2000;

if(a>b && a>c)
System.out.println("a is the greatest number");
else if(b>c)
System.out.println("b is the greatest number");
else
System.out.println("c is the greatest number");
}
}

71. //yogesh seroke
//yes no cancle using if else
import java.util.Scanner;
class YesNoCancleusingifelse
{
public static void main(String[]arg)
{
Scanner sc=new Scanner(System.in);
System.out.println("enter the value");
char ch=sc.next().charAt(0);
if(ch=='y')
System.out.println("yes");
else if(ch=='n')
System.out.println("no");
else if(ch=='c')
System.out.println("cancle");
else
System.out.println("other");
}
}

72. //yogesh seroke
//digits
import java.util.Scanner;
class Check1digit2digit3digitndabove3digitnumber
{
public static void main(String[]arg)
{
Scanner sc=new Scanner(System.in);
System.out.println("enter digits...");
int num=sc.nextInt();

if(num<=9)
{
System.out.println("1");
}
else if(num<=99)
{
System.out.println("2");
}
else if(num<=999)
{
System.out.println("3");
}
else
{
System.out.println("above 3 digit");
}
}
}

73. //yogesh seroke
//marksheet
class Marksheet
{
public static void main(String[]arg)
{
int m1=29, m2=86, m3=80, m4=89, m5=66;

if((m1>=0&&m1<=100)&&(m2>=0&&m2<=100)&&(m3>=0&&m3<=100)&&(m4>=0&&m4<=100)&&(m5>=0&&m5<=100))
{

int c=0;
int mark=0;
String sub="";
String dist="";

if(m1>=75)
{
dist +="physics";
}

if(m2>=75)
{
dist +="chemistry";
}

if(m3>=75)
{
dist +="maths";
}

if(m4>=75)
{
dist +="english";
}

if(m5>=75)
{
dist +="hindi";
}

if(m1<33)
{
sub +="physics";
c++;
mark=m1;
}
if(m2<33)
{
sub +="chemistry";
c++;
mark=m2;
}
if(m3<33)
{
sub +="maths";
c++;
mark=m3;
}
if(m4<33)
{
sub +="english";
c++;
mark=m4;
}
if(m5<33)
{
sub +="hindi";
c++;
mark=m5;
}

if(c==0 || (c==1&& mark>=28))
{
float per=(m1+m2+m3+m4+m5)/5;

if(per>33&&per<45)
System.out.println("pass with third division");
else if(per<60)
System.out.println("pass with second division");
else
System.out.println("pass with first division");

if(c==1)
System.out.println("pass by grace with" +5+"grace sub name is" +sub);

if(dist!="")
System.out.println("distinction subject name is" +dist);
}
else if(c==1)
{
System.out.println("try again you are suppl in" +sub);
}
else
{
System.out.println("sorry you have failed in "+sub);
}
}
else
{
System.out.println("entered sub mark should be 0 to 100");
}
}
}

74. Sandeep kelwa

class Checkmiddle
{

public static void main(String args[])
{
int a=10,b=12,c=340;
if(a>b && ac)
System.out.println("a is middle number");
else if(b>a && bc)
System.out.println("b is middle number");
else
System.out.println("c is middle number");

}

}

75. Sandeep kelwa

import java.util.Scanner;
class CalculateMarks
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter number");

int mark,g;
mark = sc.nextInt();
if(mark>=28 && mark<33)
{
g = 33-mark;
mark =mark+g;
System.out.println("Grace marks is "+g);
}
System.out.println("mark is "+mark);

}

}

76. Sandeep kelwa

class Checksq
{
public static void main(String args[])
{
int num=4;
int res=0;
if(num%2==0)
res=num*num*num;
else
res=num*num;
System.out.println(res);
}

}

77. Sandeep kelwa

class Greatest
{
public static void main(String args[])
{
int a=2,b=34,c=5;
if(a>b)
{
if(a>c)
System.out.println("a is greater");
else
System.out.println("c is greater");

}
else
{
if(b>c)
System.out.println("b is greatest");
else
System.out.println("c is greatest");

}

}

}

78. Sandeep kelwa

class Checkmiddle
{

public static void main(String args[])
{
int a=10,b=12,c=340;
if(a>b && ac)
System.out.println("a is middle number");
else if(b>a && bc)
System.out.println("b is middle number");
else
System.out.println("c is middle number");

}

}

79. import java .util.Scanner;
class Display
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
char ch;
System.out.println("Enter the Charactore");
ch= sc.next().charAt(0);
if(ch=='y')
{
System.out.println("Yes");
}
else if(ch=='n')
{
System.out.println("NO");
}
else if(ch=='c')
{
System.out.println("Cancel");
}

else{

System.out.println("Other");
}
}
}

80. import java.util.Scanner;
class CheckM
{

public static void main(String args[])
{
int a,b,c;
Scanner sc=new Scanner(System.in);

System.out.println("Enter the A Number");
a=sc.nextInt();
System.out.println("Enter the B Number");
b=sc.nextInt();
System.out.println("Enter the C Number");
c=sc.nextInt();

if(a>b && ac)
System.out.println("a is middle number");
else if(b>a && bc)
System.out.println("b is middle number");
else
System.out.println("c is middle number");

}

}

81. import java.util.Scanner;
class Checkdigit
{
public static void main(String[]arg)
{
Scanner sc=new Scanner(System.in);
System.out.println("enter digits...");
int num=sc.nextInt();

if(num<=9)
{
System.out.println("One Digit");
}
else if(num<=99)
{
System.out.println("Two Digit");
}
else if(num<=999)
{
System.out.println("Three Digit");
}
else
{
System.out.println("above 3 digit");
}
}
}

82. Sandeep kelwa
import java.util.Scanner;
class CheckVC
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
char ch;
System.out.println("Enter char");
ch = sc.next().charAt(0);
String s="";
if(ch=='a')
s = "Vowel";
else{
if(ch=='e')
s = "Vowel";
else
{
if(ch=='i')
s = "Vowel";
else
{
if(ch=='o')
s="Vowel";
else
{
if(ch=='u')
s = "Vowel";
else
s="consonent";
}
}
}
}
System.out.println(s);
}
}

83. Sandeep kelwa
import java.util.Scanner;
class CheckVC
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
char ch;
System.out.println("Enter char");
ch = sc.next().charAt(0);
String s="";
if(ch=='a')
s = "Vowel";
else{
if(ch=='e')
s = "Vowel";
else
{
if(ch=='i')
s = "Vowel";
else
{
if(ch=='o')
s="Vowel";
else
{
if(ch=='u')
s = "Vowel";
else
s="consonent";
}
}
}
}
System.out.println(s);
}
}

84. Sandeep kelwa
import java.util.Scanner;
class CovidResult
{
public static void main(String args[])
{
System.out.println("Enter covid result");
if(new Scanner (System.in).next().equals("positive"))
{
System.out.println("you are quarantine for 15 days");
}
}
}

85. WAP to check vowel and consonant?

public static void main(String[] args)
{
char ch;
Scanner rey = new Scanner(System.in);

System.out.println(" Enter Any String To Check Vowels And Cosonent :");
ch = rey.next().charAt(0);

if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='A'||ch=='E'||ch=='I'||ch=='o'||ch=='u')
{
System.out.println("Given Character is/are vowel = "+ch);
}
else
{
System.out.println("Given Character is/are consonent = "+ch);
}

}