View the step-by-step solution to:

Question

This is the example of execution that I need to create.


1)

Enter the number to be used:

25

Enter the interval between numbers to add: 8

Adding 0

Adding 8

Adding 16

Adding 24

The sum of the numbers from 1 to 25 at interval, 8, is 48.


2)

Enter the number to be used: 500

Enter the interval between numbers to add: 100

Adding 0

Adding 100

Adding 200

Adding 300

Adding 400

Adding 500

The sum of the numbers from 1 to 500 at interval, 100, is 1500.



And this is the code that I got it so far.


import java.util.Scanner;

public class Repetition {

  public static void main(String[] args) {

   

   Scanner keyboard = new Scanner(System.in);

   

   int maximum;

   int interval;

   String sum;

   int count = 1;

   

   System.out.print("Enter the maximum numbrer to be used: ");

   maximum = keyboard.next();

   System.out.print("Enter the interval between numbers to add: ");

   interval = keyboard.next();

   

    

   for (int i = 0; i <= maximum; ) {

      count++;

   }

   

   System.out.print("The sum of the numbers from " + @@ + "to " + @@ +

            "at interval, " + interval + "is " + sum + ".");

  }

}            


But I got stuck from this.

Please help

Top Answer

View the full answer
mOp.jpg

OpenJDK Runtime Environment (build 10.0.2+13-U
buntu-lubuntu0 . 18 . 04.4)
+ javac -classpath . :/run_dir/junit-4.12. jar -
d . Main. java
+ java -classpath . : /run dir/junit-4.12. jar Ma
in
Enter...

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question