answersLogoWhite

0


Best Answer
Solution 1

public class Divisible {

int num;

int sum;

public void calculate() {

sum=0;

System.out.println("Numbers divisible by 9:");

for(num=50;num<100;num++) {

if(num%9==0) {

System.out.println(num);

sum=sum+num;

}

}

System.out.println("Sum: "+sum);

}

public static void main(String a[]) {

Divisible obj=new Divisible();

obj.calculate();

}

}


Solution 2public static void printNums() {
// We know that 54 is the first number in the range divisible by 9.
// So if we start there and add 9, we will quickly find all numbers
// in the given range which are evenly divisible by 9.

for( int i = 54; i <= 100; i += 9 ) {
System.out.println(i);

}

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

public class TestMain {

/**

* @param args

*/

public static final void main(String[] args) {

int sum = 0;

int count = 0;

for (int i = 100; i <= 200; i++){

if(i%7 == 0){

count++;

sum = sum + i;

System.out.println("The number is: " + i);

}

}

System.out.println("Number of values divisible by 7 between 100 and 200 is: " + count);

System.out.println("Sum of values divisible by 7 between 100 and 200 is: " + sum);

}

}

Output:

The number is: 105

The number is: 112

The number is: 119

The number is: 126

The number is: 133

The number is: 140

The number is: 147

The number is: 154

The number is: 161

The number is: 168

The number is: 175

The number is: 182

The number is: 189

The number is: 196

Number of values divisible by 7 between 100 and 200 is: 14

Sum of values divisible by 7 between 100 and 200 is: 2107

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

Convert the number to a string then test the string to see if the character '9' is present. If so, convert back to a number and print it.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write a java program to print numbers that have number nine up to 100?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a java script program to print first ten odd natural numbers in C?

Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.


Program for print prime all number from 1 to 100 in foxpro?

Prime numbers are numbers that are only divisible by themselves and the number 1. You can write a program to print all prime numbers from 1 to 100 in FoxPro.


Q2 Write a program to print even numbers between 10 and 50?

You can use int i; for (i = 10; i &lt;= 50; i += 2) {//print i} as a program to print even numbers between 10 and 50.


Write a C Program to print sum of squares of odd numbers?

#include


Write in BlueJ to print lucky numbers?

To print lucky numbers in java, you must give the following program: class example { static public void main(String[] args) { System.out.println("Lucky number is your favourite number which is your DOB"); } }


How do you Write a C program to print a Series of Odd Numbers and Even Numbers.?

Reference:http:cprogramming-bd.com/c_page2.aspx# strange number


How do you Write a program in 'c' language which accepts int numbers from the users print its reverse number x function which return value?

question clarity


Write the program in qbasic and add two numbers?

Cls input "enter two no.s ",a,b sum=a+b print "sum = ";sum end


How do you write a Qbasic program to display these Numbers-0112358132134?

you do this 10 print "0112358132134" use the whole of the thing


Write an assembly language program to print a to z on screen?

write a program to print A to Z on screen in c?


How do you write a program to print numbers from star one and next line star two in php?

Try the triangle program on a search engine. Replace numbers with stars and that should do the trick


Write a c program to print the 100 to 1 nos?

Write a c program to print the 100 to 1 nos