我必须为学校编写一个程序,使用参数将摄氏温度转换为华氏温度,反之亦然.我有以下问题:
让我们说温度传入arg[1]
,我可以直接应用对话方程式arg[1]
吗?
args[1] * 9 / 5 + 32
Run Code Online (Sandbox Code Playgroud)
我尝试了但是我有一个关于*
操作符的错误"操作符*未定义参数类型.我也尝试使用"*"
.
到目前为止,这是未完成的代码.
请不要给我最终的代码本身,因为我想学习而不是给出答案
public class Temperature {
public static void main(String[] args) {
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
System.out.println("Veuillez specifier c (celsius) ou f (fahrenheit) suivi de la température. Exemple argc arg32");
if (args[0].equals ("c"))
{
/*convertir en fahrenheit*/
int temperature = args[1] *9 /5 +32;
}
else if (args[0].equals ("f"))
{
/*convertir en celsius*/
}
}
}
Run Code Online (Sandbox Code Playgroud) 我刚刚开始学习javascript,并在codeacademy上进行练习,制作一个基于文本的石头剪刀游戏.我想在调试控制台之外向某人展示,但我无法弄清楚如何在html页面中显示它.
我的html文件中的代码是:
<HTML>
<HEAD>
<script src="rockpaperscissors.js"></script>
</HEAD>
<BODY>Choose rock, paper or scissors and write your choice in the text box
<p>
<A HREF="javascript:processOrder();">Click here to begin</A>
</p>
...
</BODY>
</HTML>
Run Code Online (Sandbox Code Playgroud)
我的JS中的代码是:
var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "rock";
} else if (computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
}
var compare = function (choice1, choice2) {
if (choice1 === …
Run Code Online (Sandbox Code Playgroud)