我的想法是,我应该有两个字段,我输入数字,然后我需要显示总和以及产品.
我想我会测试产品,但我不断收到"非数字"错误.任何帮助都会很棒!
<!DOCTYPE html>
<html>
<body>
<form>
First Number<br>
<input id="num1" type="text" name="num1">
<br>
Second Number:<br>
<input id="num2" type="text" name="num2">
<br><br>
<input type="button" value="Do Maths" onclick="doMath();" />
</form>
<script>
function doMath() {
var numOne = document.getElementById('num1').value;
var numTwo = document.getElementById('num2').value;
var theProduct = parseInt(my_input1) * parseInt(my_input2); document.write(theProduct);
document.write(theProduct);
}
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我无法让main读取我的构造函数.它一直说我的类不包含一个带有3个参数的构造函数.这是公开的.我不知道我做错了什么,我在成功之前做过这个,这是我用来学习测试的练习题.
public class Actor
{
//attributes
private string name;
private int awardsNum;
private bool SAGMember;
//property
private string name
{
get { return name; }
set { name = value; }
}
//constructor
public Actor(string Name, int AwardsNum, bool SAGMember)
{
this.name = Name;
this.awardsNum = AwardsNum ++;
this.SAGMember = false;
}
public Actor()
{
this.name = "Bob Smith";
this.awardsNum = 0 ;
this.SAGMember = false;
}
public override string ToString ()
{
return string.Format ("Actor: " + name + …Run Code Online (Sandbox Code Playgroud)