Write a java program that will calculate sum of all integers


Problem

Write a Java program that will print the following to the screen. A starting point will be provided to you in GitHub. Please read the comments in the GitHub files.

Using a loop, calculate and print out the sum of all integers from 1 to 100 (inclusive).
Using a loop, calculate and print out the sum of 1+12+13+?+11001+12+13+?+1100 using float.
Using a loop, calculate and print out the sum of 1100+199+?+12+11100+199+?+12+1 using float.

The code is as below please complete the code as it is asked to be completed, It should be exacy in the needed output formate as it should be able to pass the auto grading on the github

public class Summation {
/**
* Calculates the sum of all integers from 1 to 100
*/
public static int sum1to100(){
int sum = 0;
// Write code here
return sum;
}
/**
* Calculates the sum of a harmonic series from n=1 to 100
*/
public static float sumHarmonicForward(){
float sum = 0;
// Write code here
return sum;
}
/**
* Calculates the sum of the harmonic series from n = 100 to 1
*/
public static float sumHarmonicBackward(){
float sum = 0;
// Write code here
return sum;
}
public static void main(String[] args){
System.out.println(sum1to100());
System.out.println(sumHarmonicForward());
System.out.println(sumHarmonicBackward());
}
}

The expected output should be exactly as below :-

5050
5.187378
5.187377.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Write a java program that will calculate sum of all integers
Reference No:- TGS03225432

Expected delivery within 24 Hours