$29.99
Purpose:
Task1:
Suppose ๐ is 2*( last-two digits of the PantherID + 5).
๐ ๐
โ Write a program that sums 30 even numbers after (including ) [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:
Task2:
Suppose ๐ is the last digit of you PantherID; ๐ = ๐ + 5.
๐
โ Draw a Square whose side length is with two methods. The first method is called FLside(๐๐๐ก ๐) with an integer parameter that indicates the number of “x” to draw this side. The second method is called Mside(๐๐๐ก ๐) with an integer parameter; in this method, only the first and last position will draw “x”, the other positions are fulfilled by “a”. The example below shows the example of a square whose length is 26.
โ Calculate the area of the square by writing a method called Area(๐๐๐ก ๐) with an integer parameter.
Expected Output of Task 2:
Template for Task1:
//Name: Danyang Zheng
//PantherID:000-000-026
//======================================= 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));
}
}
Template for Task2:
//Name: Danyang Zheng
//PantherID:000-000-026
//=======================================
public class Lab_02{
//The method to draw the first and last side public static void LFside(int n){
}
//The method to draw the intermediate side public static void Mside(int n){
}
//The method to calculate the area of the square
public static void Area(int n){
}
public static void main(String[] args){
//Initialize the value of n int n = 26 + 5;
//Draw first side
LFside(n);
//Draw intermediate sides
for(){
Mside(n);
}
//Draw last side
LFside(n);
//Calculate and print the area of the square
Area(n);
}
}
Criteria:
1. Upload all of the .java and the .class files to the CSc1302 dropbox on http:// icollege.gsu.edu.
3. Please comment the important lines in the .java file as shown in the template. The important lines including but not limited to i) variables, ii) for-loop, iii) while-loop, iv) if-else statement, iv) methods. Please use your own words to describe what is your purpose to write this line. A .java file without comment will be graded under a 40% penalty.
4. Make sure that both the .java and .class files are named and uploaded to icollege correctly. If any special package is used in the program, be sure to upload the package too. Should you use any other subdirectory (whatsoever) your program would not be graded, and you will receive a 0 (zero).
5. No copying allowed. If it is found that students copy from each other, all of these programs will get 0.