+ 1
Java program
Write a program to find the sum of the following series: (1∗ 1)+(2∗ 2)+(3∗ 3)+(4∗4)+...+(n∗ n) Output: User input: 6 1∗ 1=1 2∗ 2=4 3∗ 3=9 4∗ 4=16 5∗ 5=25 6∗ 6=36 The summation of the series: 91
4 ответов
+ 10
اميره القرني
to get useful help from the community, we need to see your attempt first. without having seen your code, it is difficult to find out where the issue is.
=> please put your code in playground and link it here
thanks!
+ 6
اميره القرني
Hint -
1 - Use for loop and start iteration from 1 to userinput
2 - get square of each iteration value
3 - get sum of each square value.
+ 1
class Series
{
public static void main(String args)
{
int n = Integer.parseInt(args[0]);
int s=0;
for(int i=1;i<=n;i++)
{
System.out.println(i + “ * “ + i + “ = “ + i*i);
s+= (i*i);
}
System.out.println(“The summation of the series : “ + s);
}
}
0
اميره القرني
if you want me to explain how to solve this in Arabic ; I am ready .