0
Can anyone tell me what is wrong with this code??
I am trying to create a code that first prompts from the user the number of values he wants to add . then prompts from the user the number of the values. Then displays the sum through an alert box var i=prompt("enter the number of values whose sum is to be calculated"); var g=0; var f=0; while (g<=i) { f+=prompt("enter the values"); g++; document.write(f); } /*anyone plz tell me what is wrong with this code*/
8 Answers
+ 3
anmol saxena You wrote JavaScript code in Java language then how your code will work.
Don't put your email as code name.
https://code.sololearn.com/ckzqV2392Pr7/?ref=app
You must know Java and JavaScript both are different languages.
+ 3
Can you please tag a relevant language? your tag contains '??' which is meaningless and irrelevant.
Follow this tips for posting a question đ
https://www.sololearn.com/Discuss/333866/?ref=app
+ 1
Thank u ipang
0
I M newbie
0
anmol saxena
Go to Code Playground, create new code, this time choose Web from language choice, then paste your code into the JS tab đ
0
But it is still not working
0
anmol saxena
Can you share that new code link here so I can take a look?
Follow the below guide to sharing links đ
https://www.sololearn.com/post/75089/?ref=app
0
java.util.*;
class Main {
public static void main(String[] args) {
System.out.println("enter the number of values whose sum is to be calculated");
Scanner keyboard = new Scanner(System.in);
var i = keyboard.nextInt();
var g=0;
var f=0;
while (g<i)
{
System.out.println("enter the values");
f+=keyboard.nextInt();
g++;
}
System.out.println("The sum is : " + f);
}
}