write a program to accept a string and display the new string after removing all the vowels from the string
eg
input:Computer Applications with BlueJ
output:Cmptr pplctns wth BlJ
class test
{
void main(String a)
{
char d;for(int c=0;c < a.length();c++)
{
d=a.charAt(c);
if(d!='a' && d!='A' && d!='e' && d!='E' && d!='i' && d!='I' && d!='o' && d!='O' && d!='u' && d!='U')System.out.print(d);
}
}
}
From :http://icse.fairtopic.com
Monday, February 4, 2008
ICSE JAVA String Program
Posted by
Blogger 2.o
at
7:58 PM
0
comments
Labels: BLUEJ, computer icse, computer program, for icse students, free, JAVA, JAVA program, JAVA related questions, Questions, Tests
Wednesday, January 23, 2008
Write a java program that checks whether a given NUMBER is palindrome or not.
Write a java program that checks whether a given NUMBER is palindrome or not.
import java.io.*;
public class Palindromenumber
{
public static void main(String args[])throws IOException
{
DataInputStream din=new DataInputStream(System.in);
int num,remainder,result=0,n;
System.out.println("Enter the number:");
String s=din.readLine();num = Integer.parseInt(s);
n=num;
while(num>0)
{
remainder = num%10;result = result * 10 + remainder;num = num/10;
}
if(n==result)
{
System.out.println(n+"is palindrome" );
}else
{
System.out.println(n+" is not palindrome" );
}
}
}
Posted by
Blogger 2.o
at
11:59 PM
0
comments
Labels: BLUEJ, computer icse, computer program, for icse students, icse, ICSE 2008 Exam, isc, JAVA, JAVA program, JAVA related questions, model test paper, palindrome
Write a java program to display the product of two given matrices
Write a java program to display the product of two given matrices
public class Matrix
{
public static void main(String args[])
{
int a[][] ={{ 1, 2, 5 },{ 3, 4, 4 },{ 5, 6, 2 },};
int b[][] ={{ 7, 8, 9 },{ 1, 2, 3 },{ 4, 9, 5 },};
int c[][] = mult(a, b);
System.out.println("Result: ");
for (int i = 0; i < c.length; ++i)
{
System.out.print("{");
for (int j = 0; j < c.length; ++j)
{
System.out.print(" "+c[j]);
}
System.out.println("}");
}
}
public static int mult(int a[][], int b[][])[][]
{
int rows = a.length;
int cols = b[0].length;
int c[][] = new int[rows][cols];
for (int i = 0; i <>
{
for (int j = 0; j <>
{
c[j] = 0;
for (int k = 0; k <>
{
c[j]= a[k] * b[k][j]+c[j];
}
}
}
return c;
}
}
Posted by
Blogger 2.o
at
11:43 PM
0
comments
Labels: 2008, BLUEJ, computer icse, computer program, for icse students, icse, JAVA program, matrix multiplication, model test paper, Questions, Tests
JAVA Program to check a String for palindrome
//!BjueJ :IDE for icse students!
import java.io.*;
class palindrome
{
public static void main(String arg[])throws IOException
{
DataInputStream in=new DataInputStream(System.in);
int l,i,j,flag=1;
String s;
System.out.println("Enter the string:");
s=in.readLine();
l=s.length();
for(i=0,j=l-1;i<=j;i++,j--)
{
if(s.charAt(i)==s.charAt(j))
{}
else
{
flag=0;
break;
}
}
if(flag==1)
System.out.print(s+" is palindrome");
else
System.out.print(s+" is not palindrome");
}
}
//VISIT http://icse.fairtopic.com for free help
Posted by
Blogger 2.o
at
11:30 PM
2
comments
Labels: BLUEJ, BufferedReader, computer icse, computer program, for icse students, india, JAVA, JAVA program, model test paper, palindrome
JAVA icse bluej program Pythagorean triplet
Write a program to input 3 nos. and check whether they are Pythogorean Triplet . or not .The program must display the message accordingly.
some Pythagorean triplets are
( 3, 4, 5)
( 5, 12, 13)
( 7, 24, 25)
( 8, 15, 17)
( 9, 40, 41)
(11, 60, 61)
(12, 35, 37)
(13, 84, 85)
(16, 63, 65)
(20, 21, 29)
(28, 45, 53)
(33, 56, 65)
(36, 77, 85)
(39, 80, 89)
(48, 55, 73)
(65, 72, 97)
u may use them to test the program.
Answer:
//program starts
import java.io.*;
class pytha
{
void main()throws IOException
{
BufferedReader obj=new BufferedReader(new InputStreamReader(System.in));
int a,b,c;
System.out.println("enter no.");
a=Integer.parseInt(obj.readLine());
System.out.println("enter no.");
b=Integer.parseInt(obj.readLine());
System.out.println("enter no.");
c=Integer.parseInt(obj.readLine());
if (a*a==b*b+c*c)
System.out.println("They are Pythogorean Triplet");
else if(b*b==a*a+c*c)
System.out.println("They are Pythogorean Triplet ");
else if(c*c==a*a+b*b)
System.out.println("They are Pythogorean Triplet a² + b² = c² ");
else
System.out.println("Test Failed !!! They are Non Pythogorean Triplet ");
}
}
//if u want to consider a² + b² = c² only then remove first 2 conditions
Posted by
Blogger 2.o
at
8:22 PM
0
comments
Labels: BLUEJ, BufferedReader, computer icse, computer program, for icse students, icse, ICSE 2008 Exam, isc, JAVA, JAVA program, JAVA related questions, Pythagorean triplets
JAVA program for icse students
A library charges a fine for books returned late following are the charges for fine:--
First 5 Days:- 40 paise / day
6-10 days :- 60 paise /day
above 10 days:- 1 rupee /day
do with buffer reader..
import java.io.*;
class buff
{
void main()throws IOException
{
BufferedReader obj=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter no. of days");
int a;
a=Integer.parseInt(obj.readLine());
double ans=0;
if (a<=5)
ans=a*.4;
else if(a<=10)
ans= 2 + ((a-5)*.6);
else
ans= 2 + 3 + a-10;
System.out.println("Fine:"+ans);
}
}
Ask JAVA related questions at http://icse.fairtopic.com
Posted by
Blogger 2.o
at
8:06 PM
0
comments
Labels: BLUEJ, BufferedReader, computer icse, for icse students, ICSE 2008 Exam, isc, JAVA program, JAVA related questions, model test paper
JAVA ICSE BLUEJ program
Series question
WAP to print the series:-S = 1+(1+2)+(1+2+3)+ --------+(1+2+3--------+n)
//SUPPLY N AS PARAMETER URSELF
class series2
{
void main(int n)
{
int S=0;
for (int c=1;c<=n;c++)
{for (int d=1;d<=c;d++)
{
S=S+d;
}
}
System.out.println(S);
}
}
Posted by
Blogger 2.o
at
12:53 AM
0
comments