Java with BlueJ in Hindi Class X Chapter 2 Example programs

preview_player
Показать описание
Learn Java with BlueJ IDE for Class 10th - Chapter 2
Syllabus according to Class X of ICSE
Library classes in Java. Example programs 1 to 6
Рекомендации по теме
Комментарии
Автор

//Example 4
import java.util.*;
class CountCase
{
public static void main()
{
Scanner x = new Scanner(System.in);
char k;
int i, n, lc=0, uc=0;
System.out.println("How many characters you want to enter?");
n = x.nextInt();
System.out.println("Now enter "+n+" characters");
for(i=1;i<=n;i++)
{
k = x.next().charAt(0);
if(Character.isUpperCase(k))
uc++;
else
lc++;
}
System.out.println("You have entered "+ uc +" uppercase letters");
System.out.println("and "+ lc +" lowercase letters");
}
}

ComproliveHindichannel
Автор

//Example 5 Write a program to accept two numbers from the user.
// Join them to form a single number
import java.util.*;
class JoinNumber
{
public static void main()
{
Scanner x = new Scanner(System.in);
int n1, n2;
String s;
System.out.println("Enter any number");
n1 = x.nextInt();
System.out.println("Enter another number");
n2 = x.nextInt();
s =
System.out.println("The joint number will be "+s);
}
}

ComproliveHindichannel
Автор

//Example 6
import java.util.*;
class Encrypt
{
public static void main()
{
Scanner x = new Scanner(System.in);
char k, kh;
int e;
System.out.println("Enter any alphabet Capital or small");
k = x.next().charAt(0);
if(Character.isUpperCase(k))
e = (int)k + 5;
else
e = (int)k - 3;
kh = (char)e;
System.out.println("Encrypted character is " + kh);
}
}

ComproliveHindichannel
Автор

//Example 3
import java.util.*;
class sumASCII
{
public static void main()
{
Scanner x = new Scanner(System.in);
char k;
int i, sum=0;
System.out.println("Enter any 10 characters");
for(i=1;i<=10;i++)
{
k = (x.next().charAt(0));
sum = sum+(int)k;
}
System.out.println(" Sum of ASCII codes is = "+sum);
}
}

ComproliveHindichannel
Автор

//Example 2
import java.util.*;
public class ChangeCase
{
public static void main(String args[])
{
Scanner x = new Scanner(System.in);
char k, k1;
System.out.println("Enter a character letter");
k = x.next().charAt(0);

{
k1 = Character.toLowerCase(k);
System.out.println("The lowercase of " + k + " is " + k1);
System.out.println("The ASCII value of " + k1 + " is " + (int)k1);
}
else
{
k1 = Character.toUpperCase(k);
System.out.println("The uppercase of "+ k + " is "+ k1);
System.out.println("The ASCII value of " + k1 +" is "+ (int)k1);
}
}
}

ComproliveHindichannel
Автор

//Example 1
import java.util.*;
public class Findout
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
char k;
System.out.println("Enter a Character");
k = in.next().charAt(0);

{

System.out.println(k+" is a uppercase letter ");

System.out.println(k+" is a lowercase letter ");
}
else
{

System.out.println(k+" is a number");
else
System.out.println(k+" is a special character");
}
}
}

ComproliveHindichannel