answersLogoWhite

0

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

15y ago

What else can I help you with?

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.


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"); } }


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

Oh, what a lovely request! In FoxPro, you can create a program to print all prime numbers from 1 to 100 by using a loop to check each number for divisibility only by 1 and itself. If it meets this criteria, you can print it out on the screen. Remember, every number is unique and special, just like a happy little tree in a vast forest.


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