+ 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); } }
5 Respuestas
+ 1
can you explain in detail. Please.
+ 1
Thank you so much. 😇🙏 Now I am going to follow you🤗 ~ swim ~