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
Saturday, January 26, 2008
ICSE Computer JAVA question
Guess the output of this java program.
class CoolProg
{
static void main()
{
System.out.println(Math.random());
System.out.println("over"+2+3);
System.out.println(2+3+"over"+0);
System.out.println(2+3+"over");
System.out.println(2+3+'A'+-1);
System.out.println('a'+"bhas");
System.out.println('A'+ 2);
System.out.println('A'+ 2);
int b=1;
int c=-b;
System.out.println(-b);
System.out.println(c);
String s="abhas";
System.out.println(s.substring(3,5));
System.out.println(s.substring(0,3));
System.out.println(s.substring(4));
System.out.println(s.substring(2));
}
}
/* * answer
0.6834987231679766 (random no less than 1)
over23
5over0
5over
69
abhas
67
67
-1
-1
as
abh
s
has
*/
Posted by
Blogger 2.o
at
7:13 AM
0
comments
Labels: computer icse, computer program, icse, ICSE 2008 Exam, JAVA, JAVA program, JAVA related questions, model test paper, Questions
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
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