Computer Applications
Write a program to display all the numbers between 100 and 200 which don't contain zeros at any position.
For example: 111, 112, 113, ……. , 199
Answer
public class KboatNoZero
{
public void display() {
int count = 0;
for (int i = 100; i <= 200; i++) {
boolean isNoZero = true;
int t = i;
while (t > 0) {
if (t % 10 == 0) {
isNoZero = false;
break;
}
t /= 10;
}
if (isNoZero) {
System.out.print(i + " ");
count++;
}
//This will print 10 numbers per line
if (count == 10) {
System.out.println();
count = 0;
}
}
}
}
Variable Description Table
Program Explanation
Output
Related Questions
In an entrance examination, students have been appeared in English, Maths and Science papers. Write a program to calculate and display average marks obtained by all the students. Take number of students appeared and marks obtained in all three subjects by every student along with the name as inputs.
Display the name, marks obtained in three subjects and the average of all the students.Write a program in Java to find the sum of the following series:
S = (2/a) + (3/a2) + (5/a3) + (7/a4) + ……. to n
Write a program to input two numbers and check whether they are twin prime numbers or not.
Hint: Twin prime numbers are the prime numbers whose difference is 2.
For example: (5,7), (11,13), ……. and so on.Write a program to display all prime palindrome numbers between 10 and 1000.
[Hint: A number which is prime as well a palindrome is said to be 'Prime Palindrome' number.]
For example: 11, 101, 131, 151,