小编Mar*_*ark的帖子

解析 Float 和 toFixed()

我有我的代码并且它正在工作,但我正在尝试将 parseFloat 选项和“toFixed()”添加到小数点后两位。我对这两行代码应该放在哪里感到困惑。我创建了一个单位转换网站,可以将用户输入的英寸数转换为英尺。

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <center><title>Unit Coversion Table</title><center>
</head>
<body>

<div id="question">
  <h2>Unit Convertor</h2>
  <p>Enter a Quanity of Inches: <input id="userinches" type="number" /> </p>
</div>  <!-- End of question div section -->

<div id="conversion">
  <script>
    function feet() {
      var userinches = document.getElementById('userinches').value;
      doOuput('The answer is ', userinches * 0.0833);
    }

    function doOuput(val, unit) {
      document.getElementById('results').innerHTML = val + unit;
    }
  </script>
</div>  <!-- End of conversion div section -->

<div="buttons">
  <button type="button" id="buttonft" onclick="feet();">Feet</button>
</div> <!-- …
Run Code Online (Sandbox Code Playgroud)

html javascript css parsefloat tofixed

3
推荐指数
1
解决办法
9178
查看次数

如果使用scan java时声明

我正在尝试读取用户给出的行并将其打印出正确的内容.现在,当我进入朱利安时,它不会打印任何东西.

import java.util.Scanner;

public class fantasyFootball {

    public static void main(String[ ] args) {
        Scanner reader = new Scanner(System.in); 
        System.out.println("Enter a name: ");
        String n = reader.toString();

        if("Julian".equals(n)){ 
            System.out.println("Win and Win: You go to the Playoffs");
            System.out.println("Lose and Win: ");
            System.out.println("Lose and Win: ");
            System.out.println("Lose and Lose: ");
        }
        reader.close();
    } 
}
Run Code Online (Sandbox Code Playgroud)

java java.util.scanner

1
推荐指数
1
解决办法
278
查看次数

标签 统计

css ×1

html ×1

java ×1

java.util.scanner ×1

javascript ×1

parsefloat ×1

tofixed ×1