Question

Write a program that uses a for loop to count how many multiples of 7 are...

Write a program that uses a for loop to count how many multiples of 7 are between 33 and 97, inclusive.

0 0
Add a comment Improve this question Transcribed image text
Answer #1


/*
CountMultiples.java
*/

public class CountMultiples
{
   public static void main(String args[])
   {
       int count=0;
       int sum=0;
      
       for(int i=33;i<=97;++i)
       {
            if(i%7==0)
            {
                ++count;
                sum += i;
            }
          
       }
       System.out.println("Total count of multiples of 7 between "+33+" and " +97 +" = "+count);
       System.out.println("Total sum of all multiples of 7 between "+33+" and " +97 +" =" +sum);
   }
}

Add a comment
Know the answer?
Add Answer to:
Write a program that uses a for loop to count how many multiples of 7 are...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT