Import Java
Import Java
*;
String s = scanner.nextLine();
int dC = 0;
int sC = 0;
int cC = 0;
int aC = 0;
int spC = 0;
int vC = 0;
int wC = 1;
char ch = s.charAt(i);
if (Character.isDigit(ch)) {
dC++;
} else if (Character.isLowerCase(ch)) {
sC++;
aC++;
vC++;
} else if (C…
import java.util.*;
class STRINGGG
System.out.println("Enter a word:");
c = str.charAt(i);
if ( c == 'E')
else
import java.util.*;
class STRINGGGG
{
System.out.println("Enter a sentence:");
String s = sc.nextLine();
char ch = s.charAt(i);
if (Character.isLetter(ch))
str += ch;
import java.util.*;
class BinaryToDecimal
{
int b,i,j=0,k;
double sum=0.0;
b=sc.nextInt();
while (b!=0)
i=(b%10);
sum=(sum + (i*Math.pow(2,j)));
b=(b/10);
j+=1;
/**
Data members:
basicPay, specialAlw, conveyanceAlw, gross, pf, netSalary, annualSal (double data types)
Member methods:
netSalary = gross – pf
c) void display(): To display the name and other calculations with suitable headings.
*/
import java.util.*;
class Salary…
import java.util.*;
class ShoppingCart
int c = 0;
while (true)
System.out.println("3. Exit");
int ch = sc.nextInt();
case 1:
if (c < cart.length)
do
import java.util.*;
class RestaurantMenu
int orderCount = 0;
while (true)
System.out.print("Choose an…
import java.util.*;
if(isStrongPassword(password))
System.out.println("Password is strong.");
else
System.out.println("Password is weak.");
sc.close();
if(password.length() < 8)
return false;
for(ch…
import java.util.*;
class CountdownTimer
int time;
long s = 2000200000;
time = sc.nextInt();
time--;
System.out.println("Time's up!");
}
}
/**
A class Iscscores defines the scores of a candidate in six subjects and another
Class name :
Iscscores
int number[6][2]
Member functions/methods
Iscscores() :
int point() :
80-89 2 point
70-79 3 point
60-69 4 point
50-59 5 point
40-99 6 point
-accordingly.
Class name
bestfour
Member functions/methods
void bestsubjects(): to display the total points and best four subject codes using the concept
of inh…
/**
6. Define a class PhoneBill with the following descriptions:
Data members:
Methods:
accept(): to accept customer name, phone number, number of units and rent.
calculate(): to calculate the amount as rent + cost for the units, where cost for the units
display(): to display the values of all the data members on the screen.
*/
import java.util.*;
class PhoneBill
String customerName;
long phoneNo;
int n…
import java.util.*;
int bookCount = 0;
while (true)
System.out.println("4. Exit");
int ch = sc.nextInt();
switch (ch)
case 1:
import java.util.*;
int enteredPassword;
int attempts = 0;
int maxAttempts = 3;
do
enteredPassword = sc.nextInt();
if (enteredPassword==correctPassword)
System.out.println("Authentication successful!");
break;
else
attempts++;
while (…
import java.util.*;
if(contact.equals(nameToFind))
found = true;
break;
if(found) {
} else {
/**
Write a program in Java to store 10 numbers (including positive and negative numbers) in a
Single Dimensional Array (SDA).
Display all the negative numbers followed by the positive numbers without changing the
order of the numbers.
*/
import java.util.*;
class POS_NEG
{
Scanner sc = new Scanner(System.in);
a[i] =sc.nextInt();
if (a[i] < 0)
if (a[i] > 0)
import java.util.*;
while (true)
System.out.println("4. Exit");
int ch = sc.nextInt();
switch (ch)
case 1:
break;
case 2:
System.out.prin…
/**
5. Accept numbers into an integer array A of size 4, create another string array B of size 3.
Accept any three mathematical symbols like (+, -, *, /) in array B. Then according to
mathematical symbol calculate the answer.
For e.g. if A = [8, 6, 4, 2] & B = [+, -, *], then answer will be (((8 + 6) - 4) * 2) = 20
*/
import java.util.*;
class Calculation
A[i] = sc.nextInt();
B[i] = sc.next().charAt(0);
for (int i = 0; i…
/**
Create a class named Pizza that stores details about a pizza. It should contain the following:
Instance Variables:
String pizzaSize — to store the size of the pizza (small, medium, or large)
Member Methods:
CalculateCost() — A public method that returns a double value, that is, the cost of the pizza.
3) the …
import java.util.*;
while (true)
int ch = sc.nextInt();
swit…
import java.util.*;
class sel
{
int min;
int s = sc.nextInt();
sc.nextLine();
a[i] = sc.nextLine();
min = i;
if (a[j].compareTo(a[min]) < 0)
min = j;
a[i] = a[min…
/**
2. Define a class named four Side, having members as:
Member Functions:
Also create the main() method to show the implementation of the above methods.
*/
import java.util.*;
class FourSide
length = side;
breadth = side;
length = l;
breadth = b;
…
import java.util.*;
class Author
String name;
String nationality;
name = n;
nationality = na;
String books[];
int bookCount;
bookCount = 0;
}
books[bookCount] = bookTitle;
bookCount++;
import java.util.*;
class CopyOfShoppingCart
int c = 0;
while (true)
System.out.println("3. Exit");
int ch = sc.nextInt();
switch (ch)
{
case 1:
do
import java.util.*;
class Overload
int a = 2;
if (a%j==0)
c++;
if (c==2)
s+=a;
a++;
int a = 5, b = 10, c;
c = (a+b);
a = b;
b = c;
int s = 0;
if (j % 4 == 1) {
s += Math.pow(x, j);
} else {
s -= Math.pow(x, j);
}
//2. Write a function in java to accept a String and find the frequency of a word entered by
the user in a string.
import java.util.*;
class frequency
int f = 0;
System.out.println("Enter a string");
String s = sc.next();
String t = "";
char ch = str.charAt(i);
t = t + ch;
else
if (t.compareTo(s) == 0)
…
import java.util.*;
class encode
System.out.println("Enter a string");
String s = sc.nextLine();
int l = s.length();
char ch = s.charAt(i);
if ( ch != ' ')
} else
else
}
}
System.out.println(str);
import java.util.*;
class j2015_Parkinglot
double bill;
vno = v;
hours = h;
hours--;
bill = 3 + (1.5*hours);
int v = sc.nextInt();
int h = sc.nextInt();
j2015_Parkinglot o…
import java.util.*;
class j2015_Pattern
if (j%2==0)
else
System.out.println();
System.out.println();
}
}
import java.util.*;
class j2015_factorial {
System.out.println("Choose");
int ch = sc.nextInt();
switch (ch) {
case 1:
int n = sc.nextInt();
if (n%i==0)
break;
case 2:
int f =1;
f = f*i;
default:
System.out.println("Invalid Option");
break;
import java.util.*;
class j2015_Array {
names[i] = sc.nextLine();
String t = names[j];
names[j + 1] = t;
System.out.println(name);
/**
int days To store the number of days the bike is taken on rent
Days Charge
Output:
Bike No. Phone No. Name No. of days …
/**
IC
ICS
ICSE
*/
class Pattern {
String s = "ICSE";
int l = s.length();
System.out.println(s.substring(0, i));
//Write a function in java to accept a String and find the frequency of each character
import java.util.Scanner;
class CharFreq {
String s = sc.nextLine();
int l = s.length();
int c = 1;
for (int i = 0; i < l; i++) {
ch[i] = s.charAt(i);
ch[j + 1] = temp;
import java.util.*;
class UniqueNum
n = sc.nextInt();
n1 = n;
n2 = n;
while (n1!=0)
r1 = (n1%10);
while (n2!=0)
r2 = (n2%10);
if (r1==r2)
c++;
n2 = (n2/10);
n1=(n1/10);
if (c==1)
else
import java.util.*;
class AreaCalculator {
double area(int s) {
return s*s;
return l*w;
}
double area(double r) {
return 3.14*r*r;
return 0.5*b*h;
System.out.println("Choose");
int ch = sc.nextInt();
switch (ch)
import java.util.*;
class Series1 {
int s = 0;
s+=i;
}
for (int j = 1; j<=10; j++) {
s-=j;
import java.util.*;
class Series2 {
p= (p*10)+5;
s=p/(Math.pow(10,i));
/**
Write a program to display all Mersenne numbers between 1... n using the method name
MersenneNos (int n) where n has to be in the range 1-20.
[Mersenne numbers are the ones which are one less than the power of 2]
*/
import java.util.*;
class Mersenne {
void MersenneNos(int n) {
int m = p - 1;
System.out.println(m);
int n = sc.nextInt();
obj.MersenneNos(n);
/**
An electricity board charges the bill depending on the number of units consumed as follows:
*/
import java.util.*;
class EBill {
int u = sc.nextInt();
if ( u >= 100)
bill = (u*40);
else
/**
(i) 2 4 6 8 10....20
*/
import java.util.*;
class Series1 {
System.out.println("Series (i):");
int n = sc.nextInt();
System.out.println("Series (ii):");
}
}
/**
Write a program to enter elements in the square matrix of n x n order and display sum of its
right diagonal elements.
*/
import java.util.*;
class diag {
int m = sc.nextInt();
matrix[i][j] = sc.nextInt();
int s = 0;
s += matrix[i][m - 1 - i];
/**
Define a class to accept different name and weight in kg for n number of children in a two
different arrays in an ascending order (weight).
Input weight to search whether it is present in the array or not (using Binary Search
Technique).
If it is present then display the corresponding name and if it is not then display an
appropriate message
*/
import java.util.*;
class Weight {
String names[];
double weights[];
void inputDetails(int n) {
names[i…
/**
*/
class Stock {
String item;
item=a;
qty=b;
rate=c;
amt=qty*rate;
void display() {
System.out.println("Quantity: "+qty);
int pqty;
double prate;
super(a, b, c);
pqty=d;
prate=e;
void update() {
qty += pqty;
if(prate != rate) {
rate=prate;
amt = qty*rate;
void …
/**
*
*/
import java.util.*;
class Stock {
String item;
item=a;
qty=b;
rate=c;
amt=qty*rate;
void display() {
System.out.println("Quantity: "+qty);
int pqty;
double prate;
super(a, b, c);
pqty=d;
prate=e;
void update() {
qty += pqty;
if(prate != rate) {
rate=prate;
amt = qty*rate;
/**
WAP to input any number from the user and check and display whether is a Boring Number
or not a Boring Number.
Boring Number: A positive number is called boring if all of the digits of f positions in the
number are even and all For example, the number of the digits at odd positions are old
Input: 1478
[As the odd positions include the digits (1, 7) which are odd and even positions inchad the
digits 14, 8l which are even.]
*/
import java.util.*;
class Boring {
int n = sc.nextInt();
int t = n;
int p = 1, c = 0;
while (t != 0) {
int…
import java.util.*;
class Array {
public static void main(String args[])
int n = sc.nextInt();
int c =0;
a[i] = sc.nextInt();
int t = a[i];
int nt = 0;
while (t>0) {
int r = t%10;
nt = (nt*10) + r;
t = t/10;
System.out.println("\t…
import java.util.*;
class Bill {
String name;
int table;
double bill;
this.name = name;
this.table = table;
this.bill = bill;
String s = sc.nextLine();
int n = sc.nextInt();
ob.displayBill();
/**
*/
import java.util.*;
class CelFan {
double C, F;
System.out.println("Enter choice");
int ch = sc.nextInt();
switch (ch) {
case 1:
C = sc.nextDouble();
F = (C * (9/5)) + 32;
System.out.println("Temp…
/**
Write a program to create the square matrix of order 3 3 and input numbers in it and check
whether the matrix is symmetric or not. A square matrix is said to be symmetric if the
elements of the ith row and jth column are equal to the elements of jth row and ith column,
123
245
356
*/
import java.util.*;
class Symmetric {
for(int i=0;i<3;i++) {
for(int j=0;j<3;j++) {
m[i][j]=sc.nextInt();
if (m[i]…
import java.util.*;
class Railway {
int ch = sc.nextInt();
double tc = sc.nextDouble();
switch (ch) {
case 1:
break;
case 2:
break;
case 3:
System.out.println("Ticket Cos…
/**
Define a class to accept name and marks in Computer applications for 20 students in a two
different arrays.
Arrange the marks in descending order and display the names of first 10 students along with
their marks in descending order. [Bubble Sort] [15]
*/
import java.util.*;
class Marks {
for(int i=0;i<20;i++) {
name[i]=sc.nextLine();
m[i]=sc.nextInt();
double t = m[j];
import java.util.*;
int n = sc.nextInt();
double sum = 0.0;
if (i % 2 == 0) {
sum -= term;
} else {
sum += term;
System.out.println("The sum of the series for n = " + n + " is: " + sum);
import java.util.*;
int x = sc.nextInt();
int n = sc.nextInt();
System.out.println("The sum of the series for x = " + x + " and n = " + n + " is: " + sum);
}
import java.util.*;
class Sales {
s[i][j] = sc.nextInt();
int p = 0;
p += s[i][j];
import java.util.*;
class Palindrome {
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int c =0;
a[i] = sc.nextInt();
int t = a[i];
int nt = 0;
while (t>0) {
int r = t%10;
nt = (nt*10) + r;
t = t/10;
System.out.printl…
import java.util.*;
class Student {
System.out.println("Enter a string");
String s = sc.nextLine();
char ch = s.charAt(i);
char c = Character.toLowerCase(ch);
str = str + c;
char c = Character.toUpperCase(ch);
import java.util.*;
class Stock1 {
int n;
String itemName[];
int[] qty;
double price[];
n = nn;
}
public void input() {
itemName[i] = sc.nextLine();
System.out.print("Quantity: ");
qty[i] = sc.nextInt();
System.out.print("Price: ");
price[i] = sc.nextDouble();
import java.util.*;
class String {
String s1 = sc.nextLine();
s1 = s1.toUpperCase();
String s2 = sc.nextLine();
s2 = s2.toUpperCase();
String w = "";
char ch = s1.charAt(i);
char chr = s2.charAt(i);
if ((ch == 'A' || ch == 'E' ||ch == 'I' ||ch == 'O' ||ch == 'U') && (chr == 'A' || chr == 'E'
||chr == 'I' ||chr == 'O' ||chr == 'U') && (i == 0)) {
el…
/**
A name is to be said as odd name if the ASCII code of each character become an odd
number.
WAP to accept a name and check whether the given name is odd name or not.
*/
import java.util.*;
class ASCII {
String s = sc.nextLine();
char ch = s.charAt(i);
if ((int) ch % 2 != 0) {
pos = i;
else {
System.exit(0);
if (pos != -1) {
System.out.println("The name '" + s + "' is an odd name.");
/**
WAP to accept a sentence then convert each character to second next character. The
character A becomes C, Y becomes A and Z becomes B.
*/
import java.util.*;
class character {
String s = sc.nextLine();
ch+=2;
ch = 65;
ch = 66;
}
}
import java.util.*;
class convert {
String s = sc.nextLine();
s += " ";
String w = s.substring(pos,t);
if (w.compareTo("A") == 0) {
else {
pos = t + 1;
import java.util.*;
class A_javasubstring {
System.out.println("Enter 5 strings:");
s[i] = sc.next();
if (s[i].contains("java")) {
found = true;
if (!found) {
import java.util.*;
System.out.println("Enter a sentence:");
String text = sc.nextLine();
String[] uniqueKeys;
int count = 0;
System.out.println(text);
uniqueKeys = getUniqueKeys(keys);
if(null == key)
break;
for(String s : keys)
if(key.equals(s))
count++;
System.out.println("Count of ["+key+"] i…
/**
1. A library issues books on rental basis at a 2% charge on the cost price of the book per day.
As per the rules of the library, a book can be retained for 7 days without any fine. If the book
is
returned after 7 days, a fine will also be charged for the excess days as per the chart given
below:
1 to 5 2.00
6 to 10 3.00
Above 10 5.00
A super class Library has been defined. Define a sub class Compute to calculate the fine and
the total amount. The details of the members of both the classes are given below:
author : to s…
/**
Define a class to accept names and total marks in 5 subjects of 10 different students in two
different arrays.
Arrange names in alphabetical and display the names of students who scored highest and
lowest total marks. [Using Bubble sort]
*/
import java.util.*;
class SectionB_3 {
n[i] = sc.nextLine();
System.out.println("Enter the total marks of the student " + (i+1) + " in 5 subjects");
m[i] = sc.nextInt();
sc.nextLine(); //consume…
// packers
import java.util.*;
class Packers {
n = num;
w = w1;
wt = new int[n];
void calculate() {
int tw = 0;
int b = sc.nextInt();
if ( n <= 50) {
tw = (w*b);
wt[i] = tw;
tw = 0;
} else {
void display() {
int max = 0;
max = i;
…
// bro print average of totsl marks of all students and deviation lololol
import java.util.*;
class Marks {
int N = sc.nextInt();
name[i] = sc.nextLine();
totalmarks[i] = sc.nextInt();
int s = 0;
s+= totalmarks[i…
import java.util.*;
class overloadfunc {
double volume(double r) {
return v;
return v;
double v = l*h*b;
return v;
int r = sc.nextInt();
int h = sc.nextInt();
// consectuve letters
import java.util.*;
class Consecutives {
System.out.println("Enter a string");
String s = sc.next().toUpperCase();
char ch = s.charAt(i);
import java.util.*;
class tranpose {
int m = sc.nextInt();
int n = sc.nextInt();
a[i][j] = sc.nextInt();
System.out.println();
}
import java .util.*;
class selec {
n[i] = sc.nextLine();
m[i] = sc.nextInt();
int min = i;
if (n[j].compareTo(n[i]) > 0) {
min = j;
String t = n[min];
n[min] = n[i];
n[i…
// tech number
import java.util.*;
class Tech {
int n = sc.nextInt();
int t = n, c = 0, s = 0;
while (t > 0) {
int d = t%10;
c++;
t/=10;
if (c%2 != 0) {
else {
int ld = n%100;
int fd = n/100;
if (n == s) {
else {
// overload a class with series of n terms, then fibonacci till 10 terms and sum of series.
import java.util.*;
class Overload {
void series(int n) {
int c = 0, a = 2, s = 0;
while (c < n) {
if (a % i == 0) {
c++;
if (c == 2) {
s += a;
a++;
void series() {
int a = 5, b = 10;;
int c = a+b;
a = b;
b = c;
System.out…
// automorphic
import java.util.*;
class Automorphic {
int n;
Automorphic(int n) {
this.n = n;
n = num;
int t = n, c = 0;
while (t>0) {
int d = t%10;
c++;
t/=10;
int sq = n*n;
if (n == ld) {
return true;
else {
return false;
void print() {
if (!check(n)) {
System.out.println("Not Automorphic");
else {
System.out.println("Automorphic");
}
System.out.println("…
import java.util.*;
class vowel {
String s1 = sc.nextLine();
int c = 0;
char ch = s1.charAt(i);
c++;
import java.util.*;
class merge {
int n = sc.nextInt();
int m = sc.nextInt();
A[i] = sc.nextInt();
B[i] = sc.nextInt();
int a = 0, b = 0, k = 0;
C[k++] = A[a++];