answersLogoWhite

0


Best Answer

public static void main(String[] args) { int count = 0; int sum = 0; for(int i = 100; i < 200; i++) { if(i%7 == 0){ System.out.println(i); count++; sum = sum + i; } } System.out.println("Number of values divisble by 7 is: " + count); System.out.println("Sum of the values divisible by 7 is: " + sum); }

User Avatar

Wiki User

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

Wiki User

14y ago

int num = 0;

int sum = 0;

// First number greater than 100 that is divisible by 7 is 105.

// To find the next number that is divisible by 7, simply add 7.

for(int n = 105; n < 200; n+=7) {

// Update totals.

++num;

sum += n;

}

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

You will need some variables first:

amount - store the amount of "divisible by 7" integers

total - store the sum of these integers

count - a number that will control the while loop (or you can use a for loop an exclude this)

amount = 0, total = 0, and count = 101

A special math operator is also needed, it's called modulus, it's the same as division except instead of dividing a number it finds the remainder. It uses a percent sign %

Modulus (or Mod for short) is important for this type of problem, as it can easily tell us if a number is divisible by 7. If the number Mod 7 equals 0 then it means the number is divisible by 7.

Now the while loop:

while (count < 200) {

if (count % 7 == 0) {

amount++;

total += count;

}

count++;

}

When this loop is done, amount will be the amount of numbers that are divisible by 7, and total will be all of those numbers added together. Simply print those two variables using System.out.println(); and you will have your answer.

If you want to print out each number onto the screen, just insert System.out.printlin(count); into the if statement of the while loop, then every number that's divisible by 7 will be shown on screen.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

...
int sum = 0;
for (int i = 101; i <= 199; i++)
if (i % 7 == 0) sum += i;
...

...
int sum = 0;
for (int i = 101; i <= 199; i++)
if (i % 7 == 0) sum += i;
...

...
int sum = 0;
for (int i = 101; i <= 199; i++)
if (i % 7 == 0) sum += i;
...

...
int sum = 0;
for (int i = 101; i <= 199; i++)
if (i % 7 == 0) sum += i;
...

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

cls

rem a program to sum two number

read a,b

data 10,30

sum=a+b

print "the result of sum=";sum

end

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

...
int sum = 0;
for (int i = 101; i <= 199; i++)
if (i % 7 == 0) sum += i;
...

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program to find the number of and sum of all integers greater than 100 and less than 200 that are divisible by 2?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a program to find the number of and sum of all integers greater than 100 and less than 200 that are divisible by 77?

What for? There is only a 154 inside that is divisible by 77...


What positive integers are divisble a prime number?

All integers greater than one are divisible by prime numbers.


What is the smallest number that can be divisible by all integers?

There does not exist a number that is divisible by all integers. The opposite is true. The number one can divided into all integers.


Writes a c program to find the sum of all integers between 1 and n?

Write a program to find the number and sum of all integers from 100 to 300 that are divisible by 11


What is the largest integer divisible by 8589934581?

Because there are an infinite number of integers, there are an infinite number of integers that are divisible by 8589934581 (every 8589932481th to be exact). There is not one.


What is the total number of integers between 100 and 300 that are divisible by 3?

The total number of integers between 100 and 300 that are divisible by three is 66.


Can 34215 be divisible by 3?

Yes. If the integers making up the number add to a number divisible by 3, then it is divisible by 3.The integers 34215 add up to 15, so it is divisible by 3.34215/3 = 11405


Is 291 a composite number?

If you can add the integers and they add up to a number divisible by 3, then the number is divisible by 3.


All divisible numbers?

All positive integers are divisible by at least one number.


Are all the odd number divisible by 7?

Every number is divisible by any non-zero number. No, there are an infinite number of odd integers which are not evenly divisible by 7..


Is 6 divisible by 812?

No. No number can be divisible by a number greater than it. 812 is greater than 6 so 6 cannot be divisible by 812.


Is the set of integers greater than ten is finite?

No, there are an infinite number of integers. So, there would be an infinite (infinity/2-1) number of positive integers. And, there would be an infinite (infinity-10) number of integers greater than ten.