Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What is the java code for this? The goal of this lab is to write two programs, Summation and Prime, that execute simple tasks. The

image text in transcribedWhat is the java code for this?

The goal of this lab is to write two programs, Summation and Prime, that execute simple tasks. The first computes the summation of integers within a range with a gap that the user specifies. The second tests whether the integer that the user enters is a square and if not, whether it is composite or prime. Summation Let us see some execution examples first, to get the sense of how the program works. 1 % java Summation 2 Enter start end and gap: 10 100 3 3 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76 79 82 85 88 91 94 97 100 4 The total is 1705 5 % java Summation 6 Enter start end and gap: 100 10 3 7 100 97 94 91 88 85 82 79 76 73 70 67 64 61 58 55 52 49 46 43 40 37 34 31 28 25 22 19 16 13 10 8 The total is 1705 The input the user provides appears in blue. Between "Enter ..." and "The total ..." appears the numbers that the program is adding to the total. The program does the summation in two different methods, totalPlus and totalMinus. Both methods are void and receive three int parameters start, end, and gap. We anticipate that the value of gap is positive for both. In the case of totalPlus, we anticipate start end. The program, in its main method, receives values a, b, c for the three parameters and then, if a = end; i == gap ) in the case of the other. During the execution of the for-loop, the program prints the number it is adding with the statement System.out.print("" + i). At the conclusion of the loop, it executes System.out.println() to go to the next line

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Lab Manual For Database Development

Authors: Rachelle Reese

1st Custom Edition

1256741736, 978-1256741732

More Books

Students also viewed these Databases questions