+ 1

I am facing problem in taking input from user. Please can anyone tell me about error.

/* output= x + x*x + x*x*x + ........+n Its showing error in input.*/ //[Please help me to complete this code] import java.util.Scanner; class MyClass { public static void main(String[ ] args) { Scanner sc = new Scanner(System.in); int n,i; float x,num,s=0.0f; System.out .println ("enter number of terms"); n=sc.nextInt(); System.out .println ("enter value of variable"); x=sc.nextFloat(); num=x; for(i=1;i<=n;i++) { s=s+num; num=num*x; } System .out.println ("sum is " + s); } }

23rd Jan 2020, 7:24 AM
NIKHIL JOSHI
NIKHIL JOSHI - avatar
5 ответов
+ 1
can you explain in detail. Please.
2nd Feb 2020, 4:21 PM
NIKHIL JOSHI
NIKHIL JOSHI - avatar
+ 1
Thank you so much. 😇🙏 Now I am going to follow you🤗 ~ swim ~
2nd Feb 2020, 5:00 PM
NIKHIL JOSHI
NIKHIL JOSHI - avatar