i am trying to make a simple claculator using JS in which i take all input from user i am a biginner completly kinda help me. secondly i also need to do same thing in php so how can i do that if someone has idea how to take input from user in core php. P.S no html no css is needed
<script type="text/javascript">
do{
var value1=prompt("enter 1st number::"," ");
var value2=prompt("enter 2st number::"," ");
var op=prompt("Enter operator from(+,-,*,/,%age,average):");
if (op=="+")
{
var result=ParseInt(value1)+ParseInt(value2);
document.write("addition result is ="+result );
document.write("<br/>");
}
else if(op=="-")
{
var result1=ParseInt(value1)-ParseInt(value2);
document.write("substraction result is ="+result1 );
document.write("<br/>");
}
else if (op=="*")
{
var result2=ParseInt(value1)*ParseInt(value2);
document.write("multiplication result is ="+result2 );
document.write("<br/>");
}
else if (op=="/")
{
var result3=ParseInt(value1)/ParseInt(value2);
document.write("division result is ="+result3 );
document.write("<br/>");
}
else if (op=="%age")
{
var result4=(ParseInt(value1)/ParseInt(value2))*100;
document.write("division result is ="+result4 );
document.write("<br/>");
}
else if (op=="average")
{
var result5=(ParseInt(value1)+ParseInt(value2))/2;
document.write("division result is ="+result5 );
document.write("<br/>");
}
else
{
document.write("Invalid input :" );
document.write("<br/>");
}
var choice=prompt("Do you want to continue (Y/N)::"," ");
}
while(choice=="Y"||choice=="y");
</script>
Aucun commentaire:
Enregistrer un commentaire