java programming only Following the steps of the output below Task1: Suppose m is the even number right after your last-two digits of the PantherID. Write a program that sums 30 even numbers after m (including m ) [Using For-loop]. Call this method and print out the sum from the For-loop. The above arithmetic sequence will be: m, m+2, m+4, ... m+(n-1)*2, where n is 30. The sum of this sequence can be represented as S=n/2*(2m+(n-1)*2), where n is30. Use the equation to calculate and print out the sum of this sequence. Expected Output of Task 1: Template for Task1: //Name: Danyang Zheng //PantherID:62 //Due Date: June 12 //======================================= public class Lab_01{ //Method for calculating the sum of Arithmetic Sequence Public static int Arithmetic_sequence( int n, int number){ } Public static void main(String[] args ){ //Last-two digits of the Panther ID Int n = 26; //Initialize a temporary value to save the sum Int sum =; //For-loop to calculate the sum for(){ } //Print the result of the for-loop System.out.println("The result of for-loop is: " + sum); //Print the result of the method System.out.println("The result of the method is: " + Arithmetic_sequence(n, 30)); }
java programming only Following the steps of the output below
Task1:
Suppose
m
is the even number right after your last-two digits of the PantherID.
Write a program that sums 30 even numbers after
m
(including
m
) [Using For-loop]. Call
this method and print out the sum from the For-loop.
The above arithmetic sequence will be: m, m+2, m+4, ... m+(n-1)*2, where n is 30. The
sum of this sequence can be represented as S=n/2*(2m+(n-1)*2), where n is30. Use the
equation to calculate and print out the sum of this sequence.
Expected Output of Task 1:
Template for Task1:
//Name:
Danyang
Zheng
//PantherID:62
//Due Date: June 12
//=======================================
public
class
Lab_01{
//Method for calculating the sum of Arithmetic Sequence
Public static int Arithmetic_sequence( int n, int number){
}
Public static void main(String[] args
){
//Last-two digits of the Panther ID
Int n = 26;
//Initialize a temporary value to save the sum
Int sum =;
//For-loop to calculate the sum
for(){
}
//Print the result of the for-loop
System.out.println("The result of for-loop is: " + sum);
//Print the result of the method
System.out.println("The result of the method is: " + Arithmetic_sequence(n, 30));
}
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images