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
  • JAVA Program! Write a program that makes use of threading. You will have one thread count how many times a second has p...

    JAVA Program! Write a program that makes use of threading. You will have one thread count how many times a second has passed and the second thread will count how many times 3 seconds has passed This will occur in an infinite loop and the counts will be printed to the screen. Indent the count of one of the threads for easier viewing Write a program that makes use of threading. You will have one thread count how many times...

  • Write a program that will allow the user to specify how many times the program will...

    Write a program that will allow the user to specify how many times the program will loop and display the title of the program include your name in the title, print from in the loop a string and count. -Assembly Language MASM 8086

  • # 3. PUT IN PYTHON CODE # Write a program that prints a count of how...

    # 3. PUT IN PYTHON CODE # Write a program that prints a count of how many occurrences of the letter "a" # there are in q. Do to this you will have to use a loop within a loop. q = ["apple", "beans", "orange", "tangerine", "butter", "watermelon", "vinegar"] # Type your answer here:

  • write the program in VBA b. Write a program that uses a For loop to perform...

    write the program in VBA b. Write a program that uses a For loop to perform the following steps: a. Prompt the user to input two integers: firstNum and secondNum(firstNum must be less than secondNum). b. Output all odd numbers between firstNum and secondNum. c. Output the sum of all odd numbers between firstNum and secondNum. d. Output all even numbers between firstNum and second Num. e. Output the sum of all even numbers between firstNum and secondNum.

  • Write a program that prints the numbers from 1 to 100. But for multiples of three...

    Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. Hints: You can use a for loop with a range to simplify the iteration Use the modulo division operator (%) to find the remainder of a division calculation

  • Write a complete Java program that uses a for loop to compute the sum of the...

    Write a complete Java program that uses a for loop to compute the sum of the even numbers and the sum of the odd numbers between 1 and 25.

  • Using the Phyton program; Write a program using loop (use days of the week as a...

    Using the Phyton program; Write a program using loop (use days of the week as a list) to ask the user to enter the total hours spend studying for each day of the week. How many hours spent studying on Monday? How many hours spent studying on Tuesday? Count and display the number of days the user 1) studied less than 4 hours. 2) studied between 4- 8 hours 3) studied more than 8 hours

  • Javascript Write a program to generate random numbers between a user-specified range, then count and display...

    Javascript Write a program to generate random numbers between a user-specified range, then count and display the frequencies of the most / least appeared numbers. Sample Output How many random numbers? 1000000 Enter the minimum number: 100 Enter the maximum number: 200 Generated 1000000 random numbers between 100 (inclusive) and 200 (exclusive). Number 133 has the most occurrences (10197). Number 154 has the least occurrences (9749).

  • C++ Font Exercise #5: Multiples of a Number Write a C++ program that prompts the user...

    C++ Font Exercise #5: Multiples of a Number Write a C++ program that prompts the user to enter three integers, n, m, and k, where n is the lower limit, m is the upper limit of a range of positive numbers, and k is any positive number. The program then prints all multiples of the number k between n and m. Treb Sample input/ output: Charac nter the lower and upper limits: 12 93 Enter the multiple: 7 the multiples...

  • Loops: Write a program that uses a loop to diplay Pattern A below

    Loops: Write a program that uses a loop to diplay Pattern A below, followed by another loop that displays Pattern B. 

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