This code is implemented by
Name :-Neeraj Kumar Modanwal
College Name :-
C.S.J.M. Govt. Poly. Ambedkarnagar
Belong to Padrauna
City.
Assignment
:- Check the Character that who is Numeric, Alphabet, Space and Special
Symbol.
public class CharacterCheck {
public static void main(String[] args) {
char ch =' ';
if(ch>=65 &&ch<=122)
System.out.println("Character is
Alphabet.");
else if(ch>=48 &&ch<=57)
{
System.out.println("Character is
Numeric.");
}
else if(ch==32){
System.out.println("Character is
Space");
}
else{
System.out.println("Character is
Special Symbol.");
}
}
}
Result :-
Character is Space
Assignment
:- Check the the Greatest Value. Using If and without IF.
public class GreatestValue {
public static void main(String[] args) {
int a = 1000;
int b = 4500;
int c = 9800;
if(a>b)
{
if(a>c){
System.out.println(a + " Number is
Greatest.");
}
else {
System.out.println(c + " Number is
Greatest.");
}
}
else if(b>c){
System.out.println(b + " Number is
Greatest.");
}
else {
System.out.println(c + " Number is
Greatest.");
}
int result = (a>b?(a>c?a:c):b>c?b:c);
System.out.println(result + " Number is
Greatest.");
}
}
Result :-
9800 Number is Greatest.
9800 Number is Greatest.
Assignment
:-Using while, for and Do-While and print 1 to 10.
Do-WhileLoop :-
public class Counting {
public static void main(String[] args) {
int i=1;
do
{
System.out.println(i);
i++;
}
while(i<=10);
}
}
While Loop :-
public class Counting {
public static void main(String[] args) {
int i=1;
while(i<=10)
{
System.out.println(i);
i++;
}
}
}
For Loop :-
public class Counting {
public static void main(String[] args) {
for(int
i=1;i<=10;i++)
{
System.out.println(i);
}
}
}
Assignment
:- Check the the Lowest Value. Using If and without IF.
public class LowestValue {
public static void main(String[] args) {
int a = 1000;
int b = 4500;
if(a<b)
{
System.out.println(a + " Number is Lowest.");
}
else
{
System.out.println(b + " Number is
Lowest.");
}
{
int result = (a>b?a:b);
System.out.println(result + " Number is Lowest.");
}
}
Result :-
1000 Number is Lowest.
1000 Number is Lowest.
No comments:
Post a Comment