Documente Academic
Documente Profesional
Documente Cultură
aashray | Logout
Home
Resources
Class X
Class XII
Videos
Gallery
Forum
Fun
Friends (0)
Friend Requests
You have no new friend request.
Tutorials
Programming In Java
English
Computer Practical
Viva-Voce
Quick Links
For-loop
While-loop
Do-while loop
Arrays 1D
Arrays 2D
Strings
Functions
Function overloading
Recursive Functions
The first few such numbers are 4, 22, 27, 58, 85, 94, 121.....
Example 1.
666 Prime factors are 2, 3, 3 and 37
Sum of the digits are (6+6+6) = 18
Sum of the digits of the factors (2+3+3+(3+7) = 18
Sample data:
Input 94 Output SMITH Number
Input 102 Output NOT SMITH Number
View/Hide Solution
import java.util.*;
class ISCprac2011q01{
public static void main(String args[])
throws InputMismatchException{
int n;
if(n>=1000)
{
System.out.println("OUT OF RANGE");
}else{
String result,h="",t="",o="";
int a,b,c;
String ones[]={"one", "two","three","four","five","six","seven",
"eight","nine"};
String teens[]={"eleven","twelve","thirteen","fourteen","fifteen"
,"sixteen","seventeen","eighteen","nineteen"};
String tens[]={"ten","twenty","thirty","forty","fifty","sixty",
"seventy","eighty","ninety"};
}
if(n>10 && n<20){
a=n%10;
if(result!=null){
result+=" and ";
result+=teens[a-1];
}else{
result=teens[a-1];
}
}
if(n<10 && n!=0){
if(result!=null)
{
result+=" and ";
result+=ones[n-1];
}else{
result=ones[n-1];
}
OR
a=n/100;
if(n>100){
n=n%100;
}
b=n/10;
c=n%10;
if(a!=0){
h=ones[a-1]+" hundred";
}
if(b==0 && c!=0){
o=ones[c-1];
}
else if(c==0 && b!=0){
t=tens[b-1];
}
else if(b==1){
t=teens[c-1];
}
else if(b!=0 && c!=0){
t=tens[b-1]+" "+ones[c-1];
}
if(b==0 && c==0)
result=h;
else if(a==0)
result=t+" "+o;
else
result=h+" and "+t+" "+o;
System.out.println("\n"+result.toUpperCase());
}
}
}
Sentence
No. of Vowels
No. of words
4.
----------------------------------------------------------
5.
6.
7.
8.
9.
10.
11.
Sentence
12.
----------------------------------------------------------
13.
14.
15.
VVVVVVVVVVVVVVV
WWWWWWWWW
18.
19.
VVVVVV
WWW
16.
17.
No. of words/vowels
VVVVVVVVVVVVVVVVVVVVVVVV
WWWWWWWWWWWW
----------------------------------------------------------
View/Hide Solution
import java.io.*;
class ISCprac2011q02{
public static void main(String args[])throws IOException{
BufferedReader br=new BufferedReader(
new InputStreamReader(System.in));
int nos;
System.out.print("Enter number of sentences : ");
nos=Integer.parseInt(br.readLine());
if(nos<1 || nos>=10)
System.out.println("\nInvalid Entry");
else{
int i,j,p,l;
String s[]=new String[nos];
for(j=l-1;j>=0;j--){
//reverse loop to start extraction of words from last to first
char ch=s[i].charAt(j);
if(ch==' '){
t=t+s[i].substring(j+1,p)+" ";
// add the extracted word and a space
p=j;
}
}
t=t+".";
s[i]=t;
}
}
System.out.println("\nOUTPUT:");
for(i=0;i< nos;i++)
System.out.print(s[i]);
}
}
}
20. Given a square matrix list [ ] [ ] of order 'n'. The maximum value possible for 'n'
is 20. Input the value for 'n' and the positive integers in the matrix and perform
the following task:
1. Display the original matrix
2. Print the row and column position of the largest element of the matrix.
3. Print the row and column position of the second largest element of the matrix.
4. Sort the elements of the rows in the ascending order and display the new
matrix.
Sample data:
INPUT:
N=3
List [][]
21.
5 1 3
22.
7 4 6
23.
9 8 2
OUTPUT
5 1 3
7 4 6
9 8 2
View/Hide Solution
import java.util.*;
class ISCprac2011q03{
public static void main(String args[])
throws InputMismatchException{
s+=d;
System.out.print(s);
}else{
System.out.print("INVALID DATE");
}
}
}
Recently Registered
Guess Questions
Ask a Question