Java program | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

20th Oct 2021, 5:45 PM
ุงู…ูŠุฑู‡ ุงู„ู‚ุฑู†ูŠ
4 Answers
+ 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!
20th Oct 2021, 5:51 PM
Lothar
Lothar - avatar
+ 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.
20th Oct 2021, 5:54 PM
AอขJ
AอขJ - avatar
+ 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); } }
22nd Oct 2021, 7:47 AM
sree harsha
sree harsha - avatar
0
ุงู…ูŠุฑู‡ ุงู„ู‚ุฑู†ูŠ if you want me to explain how to solve this in Arabic ; I am ready .
21st Oct 2021, 4:10 PM
**๐Ÿ‡ฆ๐Ÿ‡ช|๐Ÿ‡ฆ๐Ÿ‡ช**
**๐Ÿ‡ฆ๐Ÿ‡ช|๐Ÿ‡ฆ๐Ÿ‡ช** - avatar