ICSE BlueJ Logical Program
ICSE BlueJ Logical Program
ICSE BlueJ Logical Program
3 (B + C)1/2
in(String args[])
4;
.pow((a+b),2);
.sqrt(b+c);
t(a+c);
ple Interest.
in(String args[])
100;
("Simple intrest = "+si);
rcumference of circle.
in(String args[])
;
;
("Area of the Circle of radious "+r+" is : "+a);
("Circumference : "+c);
angle.
in(String args[])
4;
2.0;
(s-a)*(s-b)*(s-c))/(2*a*b);
("Area of the Triangle");
("of sides "+a+","+b+","+c);
("is : "+area);
porting documentation to enter any three real numbers and calculate X where:
er portion
tion
in(String args[])
2 = 7.19,n3 = 3.65;
3)/(d1+d2+d3);
("The value of X is : "+x);
on:
number is divisible by 5 or not.
in(String args[])
in(String args[])
3 = = 0)
n ("The number "+n+" is divisible by 2 and 3");
rams to accept three numbers and find which one is greater (one using if statement and an
(a>c)?a:c) : ((b>c)?b:c);
The Highest Number is : "+max);
nd out the given number is divisible by 5 or not, if not then print the nearest number from
in(int n)
t the basic salary of a person. He get 15% of the basic as HRA, 15% of the basic as Conve
nt allowance. The total salary is calculated by adding Basic + HRA + Conveyance + Enterta
salary of person.
in(int basic)
.15;
basic*.15;
t = basic*.10;
= basic + HRA + conveyance + entertainment;
("Total Salary : "+totalSalary);
in(int sales)
= 0.0;
s*.03;
s*.12;
s*.31;
r the three sides of a triangle. Decide whether it is a scalene, isosceles or equilateral triang
in(String args[])
arseInt(args[0]);
arseInt(args[1]);
arseInt(args[2]);
= c && c = = a)
n ("Equileteral Triangle");
b! = c && c! = a)
n ("Scalean Triangle");
n ("Isoceles Triangle");
r books returned late. Following are the fines: first five days 40 paisa per day, Six to ten d
day. Design a program to calculate the fine assuming that a book is returned N days late.
in(int Ndays)
0;
s*.40;
ays< = 10)
s*.65;
s*.80;
("FINE AMOUNT (Rs.) : "+fineAmount);
ent wishes to compute monthly telephone bills for its customers using the following rules. M
e per unit for next 60 units, plus 50 paise per unit for next 60 units, plus 40 paise per unit
ates the monthly bill, with input MESSAGE (the number of message units) and CUSTNO (th
e bill in following format.
0)
he hourly rate (R) for the first 40 hours of work in a week. Thereafter, he is paid at 1.25 ti
t 1.5 times of the hourly rate (R) for the further hours of work in the week. Taking the num
he weekly wages (W) is to be calculated.
in(int H,int R)
= 56)
*1.25;
5+(H-56)*R*1.5;
The Weekly Wages : "+W);
pute BI-monthly telephone charges for subscriber. Use the following information:
: Rs.380
months: 120
ee limits upto 100 calls: Rs.1
ess of 100 calls: Rs. 1.25
in(int calls)
;
ls< = 220)
s-120)*1;
calls-220)*1.25;
("BILL AMOUNT : "+bill);
t the code of a particular item, quantity purchased and rate. Then calculate the purchased
he gifts to the customers are given in the following manner:
Rs.) Gift
A key ring
A leather purse
A pocket calculator
rate;
("Purchase Price : "+price);
price< = 500)
n ("Gift item : Key Ring");
ce< = 1000)
n ("Gift item : Leather Purse");
ough command line parameters, the total target amount proposed by the company and pr
ethod to calculate the salary increment of employees based on their basic pay. Calculate th
-
-
/-
e this keyword, to calculate the prize amount for a cricketer depending upon his text avera
duate Prize Amount
Rs. 1,00,000.00
Rs. 50,000.00
Rs. 25,000.00
Rs. 10,000.00
write a program in java to calculate the grade as per the given criteria:
de
Excellent
First Div.
Second Div.
Third Div.
n values the variable basic salary and calculate the DA and the gross salary and print them
en DA is 5% of basic
0 then DA is 8% of basic
0 then DA is 10% of basic
then DA is 12% of basic
DA.
in an organization. You have to display the number of employees getting Net-Salary above
ollowing the table given below.
Basic_salary) IT (% Gross_Salary)
8% 6%
15% 9%
18% 12%
ess Allowance and income Tax respectively.
lary + DA
ry - IT
0
ll
/call
)
ing to the option entered by the user and then finally display the bill.
late monthly telephone bill for a consumer after accept number of call according to given c
00/-
1.25/call
.50/call
the sales or any 20 sales men. Calculate and print the commission with an added allowanc
ed by using the following table:-
on
as three data member Name, roll and Marks of 5 Subjects the steam is assigned based on
Stream
ience with computers
cience without Computers
ommerce with Maths
ommerce without Maths
a class student and allot the stream and print them.
e charge for the parking of 2wheeler, 3wheeler and 4wheller (same charges) as per the fo
e
ional 8 hours
each addition 8 hrs.
ed and prints the charges as per given criteria.
of a country is PO and it increases by 5% every year. The population (P) after n years is gi
m to find the population every year for the next ten years.
series
in(String args[])
7;i++)
(s+" ");
in(String args[])
7;i++)
(s+" ");
in(String args[])
6;i++)
((int) Math.pow(i,2)-1 + " ");
acci series)
in(String args[])
;
+)
(a+" ");
in(String args[])
;
+)
(a+" ");
in(String args[])
5;i++)
((i*2)+" "+(i*3)+" ");
in(String args[])
+)
n (a+" ");
n (b+" ");
in(String args[])
5;i++)
ow(i,3)) - 1;
(n+" ");
ven series
+ 6 - 7 + 8 - 9 + ……………… + Nth
X+3)4+(X+4)5+…………… +(X+N)N+1
X3 + 4!X4
+ X6
in(String args[])
10;i++)
in(String args[])
arseInt(args[0]);
("The all Factors of given no. "+n+" is");
n;i++)
tln (i);
r and check whether the number is perfect number or not. A number is called perfect num
e number is equal to that number. (For e.g. 6 is a perfect number. Factors are 1, 2 & 3 and
in(String args[])
arseInt(args[0]);
in(String args[])
tln (n);
pt a number, check whether the numbers is prime number or not. If number is prime, the
UMBER".
in(String args[])
arseInt(args[0]);
in(String args[])
t (n+" ");
ude oil of a country in millions of barrel may be estimated by the following set of equations
r 0< = t< = 3 and P = 14+(T-5/2)^2, for t>3, Write a program to print the quantity of pr
pt a number then print the sum of digits and number of digits present in it. (E.g. If the inp
digits is 3).
in(int n)
pt a number then print the number in reverse order. (E.g. If the input number is 245, the
in(int number)
0, digit;
;
everseNumber*10+digit;
0;
in(int number)
;
everseNumber*10+digit;
0;
everseNumber)
n ("Number is Palindrom");
trong number if the sum of cube of each digit of the number is equal to that number. Writ
the given number is Armstrong number or not. (E.g. 153 is a Armstrong number because
in(int number)
ber, digit;
;
w(digit,3);
0;
um)
n ("Number is Armstrong");
in()
0;number< = 999;number++)
t*digit*digit);
m)
tln ("Armstrong Number is "+number);
k whether all digits of the given number are same type or not (i.e. all are odd, all even nu
pt a number and then add all digits until you found a single digit number. If that single dig
ber. (e.g. if number is 2345 then sum of its digits becomes 14, further sum of this digits is
in(int number)
10;
;
/10;
n ("Lucky Number");
*
***
*****
*******
*****
***
*
class ast1
{
public static void main(String args[])
{
int i,j;
for(i = 1;i< = 5;i++)
{
for(j = 1;j< = 40-i;j++)
System.out.print (" ");
for(j = 1;j< = i*2-1;j++)
System.out.print ("*");
System.out.println ();
}
for(i = 4;i> = 1;i--)
{
for(j = 1;j< = 40-i;j++)
System.out.print (" ");
for(j = 1;j< = i*2-1;j++)
System.out.print ("*");
System.out.println ();
}
}
}
*
*+*
*+++*
*+++++*
*+++++++*
*+++++*
*+++*
*+*
*
class ast2
{
public static void main(String args[])
{
int i,j,p = 40;
for(i = 1;i< = 5;i++,p--)
{
for(j = 1;j< = p;j++)
System.out.print (" ");
for(j = 1;j< = i*2-1;j++)
{
if(j = = 1 || j = = i*2-1)
System.out.print ("*");
else
System.out.print ("+");
}
System.out.println ();
}
p = p+2;
for(i = 4;i> = 1;i--,p++)
{
for(j = 1;j< = p;j++)
System.out.print (" ");
for(j = 1;j< = i*2-1;j++)
{
if(j = = 1 || j = = i*2-1)
System.out.print ("*");
else
System.out.ࡰrint("+");
}
System.out.println ();
}
}
}
*
***
*****
*******
class ast3
{
public static void main(String args[])
{
int i,j;
for(i = 1;i< = 5;i++)
{
for(j = 1;j< = 40-i;j++)
System.out.print (" ");
for(j = 1;j< = i*2-1;j++)
System.out.print ("*");
System.out.println ("");
}
}
}
*
***
*****
*******
* *
**
*
class ast4
{
public static void main(String args[])
{
int i,j;
for(i = 1;i< = 5;i++)
{
for(j = 1;j< = 40-i;j++)
System.out.print (" ");
for(j = 1;j< = i*2-1;j++)
System.out.print ("*");
System.out.println ("");
}
for(i = 4;i> = 1;i--)
{
for(j = 1;j< = 40-i;j++)
System.out.print (" ");
for(j = 1;j< = i*2-1;j++)
{
if(j = = 1 || j = = i*2-1)
System.out.print ("*");
else
System.out.print (" ");
}
System.out.println ("");
}
}
}
*
**
* *
* *
* *
**
*
class ast5
{
public static void main(String args[])
{
int i,j,p = 40;
for(i = 1;i< = 5;i++,p--)
{
for(j = 1;j< = p;j++)
System.out.print (" ");
for(j = 1;j< = i*2-1;j++)
{
if(j = = 1 || j = = i*2-1)
System.out.print ("*");
else
System.out.print (" ");
}
System.out.println ();
}
p = p+2;
for(i = 4;i> = 1;i--,p++)
{
for(j = 1;j< = p;j++)
System.out.print (" ");
for(j = 1;j< = i*2-1;j++)
{
if(j = = 1 || j = = i*2-1)
System.out.print ("*");
else
System.out.print (" ");
}
System.out.println ();
}
}
}
W
WE
WEL
WELC
WELCO
WELCOM
WELCOME
class pro
{
public static void main(String args[])
{
String x = "WELCOME";
int i,j;
int l = x.length();
for(i = 0;i< = l;i++)
{
for(j = 0;j<i;j++)
System.out.print (x.charAt(j));
System.out.println ();
}
}
}
A
Am
Ami
Amit
Amita
Amitab
Amitabh
class amitabh
{
public static void main(String args[])
{
String x = "Amitabh";
int i,j;
for(i = 0;i< = x.length();i++)
{
for(j = 0;j<i;j++)
System.out.print (x.charAt(j));
System.out.println ();
}
}
}
A
BB
CCC
DDDD
EEEEEE
class alpha1
{
public static void main(String args[])
{
int i,j,a = 65;
for(i = 1;i< = 5;i++,a++)
{
for(j = 1;j< = i;j++)
System.out.print ((char)a);
System.out.println ();
}
}
}
A
AB
ABC
ABCD
ABCDE
class alpha2
{
public static void main(String args[])
{
int i,j,a;
for(i = 1;i< = 5;i++)
{
a = 64;
for(j = 1;j< = i;j++)
System.out.print ((char)(a+j));
System.out.println ();
}
}
}
1111
2222
3333
4444
class pyr1
{
public static void main(String args[])
{
int i,j;
for(i = 1;i< = 4;i++)
{
for(j = 1;j< = 4;j++)
System.out.print (i);
System.out.println ();
}
}
}
0
12
345
6789
class pyr2
{
public static void main(String args[])
{
int i,j,a = 0;
for(i = 1;i< = 4;i++)
{
for(j = 1;j< = i;j++)
{
System.out.print (a);
a++;
}
System.out.println ();
}
}
}
1
12
123
1234
12345
class pyr3
{
public static void main(String args[])
{
int i,j;
for(i = 1;i< = 5;i++)
{
for(j = 1;j< = i;j++)
{
System.out.print (j);
}
System.out.println ();
}
}
}
1
21
321
4321
54321
class pyr4
{
public static void main(String args[])
{
int i,j;
for(i = 1;i< = 5;i++)
{
for(j = i;j> = 1;j--)
{
System.out.print (j);
}
System.out.println ();
}
}
}
55555
4444
333
22
1
class pyr5
{
public static void main(String args[])
{
int i,j;
for(i = 5;i> = 1;i--)
{
for(j = i;j> = 1;j--)
System.out.print (i);
System.out.println ();
}
}
}
1
22
333
4444
55555
class pyr6
{
public static void main(String args[])
{
int i,j;
for(i = 1;i< = 5;i++)
{
for(j = 1;j< = i;j++)
System.out.print (i);
System.out.println ();
}
}
}
54321
5432
543
54
5
class pyr7
{
public static void main(String args[])
{
int i,j;
for(i = 1;i< = 5;i++)
{
for(j = 5;j> = i;j--)
System.out.print (j);
System.out.println ();
}
}
}
54321
4321
321
21
1
class pyr8
{
public static void main(String args[])
{
int i,j;
for(i = 5;i> = 1;i--)
{
for(j = i;j> = 1;j--)
System.out.print (j);
System.out.println ();
}
}
}
12345
1234
123
12
1
class pyr9
{
public static void main(String args[])
{
int i,j;
for(i = 5;i> = 1;i--)
{
for(j = 1;j< = i;j++)
System.out.print (j);
System.out.println ();
}
}
}
12345
2345
345
45
5
class pyr10
{
public static void main(String args[])
{
int i,j;
for(i = 1;i< = 5;i++)
{
for(j = i;j< = 5;j++)
System.out.print (j);
System.out.println ();
}
}
}
5
45
345
2345
12345
class pyr11
{
public static void main(String args[])
{
int i,j;
for(i = 5;i> = 1;i--)
{
for(j = i;j< = 5;j++)
{
System.out.print (j);
}
System.out.println ();
}
}
}
5
54
543
5432
54321
class pyr12
{
public static void main(String args[])
{
int i,j;
for(i = 5;i> = 1;i--)
{
for(j = 5;j> = i;j--)
System.out.print (j);
System.out.println ();
}
}
}
1
212
32123
4321234
543212345
class pyr13
{
public static void main(String args[])
{
int i,j;
for(i = 1;i< = 5;i++)
{
for(j = 1;j< = 5-i;j++)
System.out.print (" ");
for(j = i;j> = 1;j--)
System.out.print (j);
for(j = 2;j< = i;j++)
System.out.print (j);
System.out.println ();
}
}
}
1
121
12321
1234321
123454321
class pyr14
{
public static void main(String args[])
{
int i,j;
for(i = 1;i< = 5;i++)
{
for(j = 1;j< = 5-i;j++)
System.out.print (" ");
for(j = 1;j< = i;j++)
System.out.print (j);
for(j = i-1;j> = 1;j--)
System.out.print (j);
System.out.println ();
}
}
}
1
232
34543
4567654
567898765
67890109876
7890123210987
890123454321098
90123456765432109
class pyr15
{
public static void main(String args[])
{
int i,j;
for(i = 1;i< = 9;i++)
{
for(j = 1;j< = 40-i;j++)
System.out.print (" ");
for(j = i;j< = (i*2)-1;j++)
System.out.print (j%10);
for(j = (i-1)*2;j> = i;j--)
System.out.print (j%10);
System.out.println ();
}
}
}
1
010
10101
0101010
101010101
class pyr16
{
public static void main(String args[])
{
int i,j,a;
for(i = 1;i< = 5;i++)
{
for(j = 1;j< = 40-i;j++)
System.out.print (" ");
a = i;
for(j = 1;j< = i*2-1;j++,a++)
System.out.print (a%2);
System.out.println ();
}
}
}
1
123
12345
1234567
123456789
class pyr17
{
public static void main(String args[])
{
int i,j;
for(i = 1;i< = 5;i++)
{
for(j = 1;j< = 5-i;j++)
System.out.print (" ");
for(j = 1;j< = (i*2-1);j++)
System.out.print (j);
System.out.println ();
}
}
}
1
222
33333
4444444
555555555
class pyr18
{
public static void main(String args[])
{
int i,j;
for(i = 1;i< = 5;i++)
{
for(j = 1;j< = 5-i;j++)
System.out.print (" ");
for(j = 1;j< = (i*2-1);j++)
System.out.print (i);
System.out.println ();
}
}
}
1 1
222 222
33333 33333
44444444444444
class pyr19
{
public static void main(String args[])
{
int i,j;
for(i = 1;i< = 4;i++)
{
for(j = 1;j< = 5-i;j++)
System.out.print (" ");
for(j = 1;j< = (i*2-1);j++)
System.out.print (i);
for(j = 1;j< = (4-i)*2;j++)
System.out.print (" ");
for(j = 1;j< = (i*2-1);j++)
System.out.print (i);
System.out.println ();
}
}
}
ICSE BlueJ String Handling
String Handling Questions for BlueJ
Home Page
(Note: All programs codes are Tested in BlueJ)
1. Accept a name and print it in reverse form. (If name is AMIT, th
class ques1
{
public static void main(String args[])
{
String n = "AMIT";
int l = n.length();
for(int i = l-1;i> = 0;i--)
{
System.out.print (n.charAt(i));
}
}
}
2. WAP to accept a name. Then display the ASCII value of each chara
class ques2
{
public static void main(String args[])
{
String n = "AMITABH";
int l = n.length();
for(int i = 0;i<l;i++)
{
int asc = (int)n.charAt(i);
System.out.println (n.charAt(i)+" --> "+asc);
}
}
}
3. WAP to read a word. Print the position of the first vowel occurr
print 'Sorry no vowel'.
class ques3
{
public static void main(String args[])
{
String n = "AMITABH";
int l = n.length();
int p = 0;
for(int i = 0;i<l;i++)
{
char c = n.charAt(i);
if(c = = 'A' || c = = 'E' || c = = 'I' || c = = 'O' || c
{
p = i+1;
break;
}
}
if(p = = 0)
System.out.println ("Vowel not found");
else
System.out.println ("Position of First Vowel "+p);
}
}
4. WAP in BASIC to take a proverbial statement (like 'Failure are t
then output the frequency of the vowels occurring in the statement.
class ques4
{
public static void main(String args[])
{
String n = "Failure are the pillars of success";
int va = 0,ve = 0,vi = 0,vo = 0,vu = 0;
for(int i = 0;i<n.length();i++)
{
char c = n.charAt(i);
if(c = = 'A' || c = = 'a') va++;
if(c = = 'E' || c = = 'e') ve++;
if(c = = 'I' || c = = 'i') vi++;
if(c = = 'O' || c = = 'o') vo++;
if(c = = 'U' || c = = 'u') vu++;
}
System.out.println ("No. of times Vowel 'A' is present : "+va);
System.out.println ("No. of times Vowel 'E' is present : "+ve);
System.out.println ("No. of times Vowel 'I' is present : "+vi);
System.out.println ("No. of times Vowel 'O' is present : "+vo);
System.out.println ("No. of times Vowel 'U' is present : "+vu);
}
}
5. WAP to enter any sentence and calculate the following:
a) Total number of digits present in it.
b) Total number of small letters and capital letters present in i
c) Total number of alphabets used in it.
d) Total number of special character used in it.
e) Total number of vowels presents in it.
f) Total Number words present in that sentence.
class ques5
{
public static void main(String args[])
{
String n = "O-16, Shiva Ganga Apartment, Sonari, Phone No. 3317
String alp = "ABCDEFGH IJKLMNOPQR STUVWXYZ";
int nd = 0,sl = 0,cl = 0,alpha = 0,nv = 0,ns = 0;
int l = n.length();
for(int i = 0;i<l;i++)
{
char c = n.charAt(i);
int asc = (int)c;
if(asc> = 48 && asc< = 57)
nd++;
if(asc> = 65 && asc< = 90)
cl++;
if(asc> = 97 && asc< = 122)
sl++;
if(c = = ' ')
ns++;
if(c = = 'A'||c = = 'a'|| c = = 'E'||c = = 'e'||c = = 'I
= = 'u')
nv++;
// calculating number of alphabets used
if(Character.isLowerCase(c))
c = Character.toUpperCase (c);
int pos = alp.indexOf(c);
if(pos! = -1)
{
alp = alp.replace(c,'0');
alpha++;
}
}
System.out.println ("Sentence is : "+n);
System.out.println ("No. of Digits (0-9) present : "+nd);
System.out.println ("No. of Small Letter : "+sl+" Capital Lette