我想输入目录的名称并检查它是否存在.如果它不存在我想创建但我得到错误mkdir: cannot create directory'./' File exists
我的代码说文件存在,即使它不存在.我究竟做错了什么?
echo "Enter directory name"
read dirname
if [[ ! -d "$dirname" ]]
then
if [ -L $dirname]
then
echo "File doesn't exist. Creating now"
mkdir ./$dirname
echo "File created"
else
echo "File exists"
fi
fi
Run Code Online (Sandbox Code Playgroud) 我在这里看了很多与我有关的问题,但他们都使用不同的方法来处理我必须使用的方法.我知道这是一个非常漫长的方式来找出有更简单的方法,但我只是按照说明.
为什么以下代码不起作用?该函数检查它是否是元音.然后检查输入以查看它的长度是否为1.如果为1,则调用该函数.如果它大于1,则在长度为1之前请求另一个输入.
我现在看到JS中不存在布尔值.我想这个问题现在无效!
function isVowel(x){
boolean result;
if(x == "A" || x == "E" || x == "I" || x == "O" || x == "U" ) {
result = true;
}
else{
result = false;
}
return result;
}
var input;
input = prompt("Enter a character ");
input = input.toUpperCase();
if(input.length == 1){
isVowel(input);
}
}
else{
while(input.length != 1){
prompt("Enter a character ");
if(input.length == 1){
isVowel(input);
}
}
}
alert(isVowel(input));
Run Code Online (Sandbox Code Playgroud) 我知道这段代码错了.我是初学者所以请耐心等待.
我需要找到最低的奇数,但无论输入什么数字,它都会保持为零.我需要初始化'最低',但我如何/在哪里初始化它?
最低= 0导致问题,但我不确定在哪里初始化最低
class Odd
{
public static void main(String[] args)
{
int number; //the number entered by the user
int input; //the amount of numbers to be entered by the user
int index;
int lowest = 0; //lowest odd number
System.out.println("How many numbers? ");
input = EasyIn.getInt();
for (index = 1; index <= input ; index ++)
{
System.out.println("Enter number " + index + ":" );
number = EasyIn.getInt();
if ((number % 2 == 1) && (number < …Run Code Online (Sandbox Code Playgroud) 我知道这可能是我做错了.我希望它在循环结束时打印最小数字等,但它总是打印为最低的零.如何让它不将退出机制归零为最低数字.
有什么建议吗?
class HighLowAve
{
public static void main (String[]args)
{
int num =0;
int sum;
int highest;
int lowest;
int index;
Double average;
highest = num;
lowest = num;
sum = 0;
index = 0;
do
{
System.out.println("Enter a number. Press zero to quit ");
num = EasyIn.getInt();
if (num > highest)
{
highest = num;
}
else if (num < lowest)
{
lowest = num;
}
sum = sum + num;
index++;
}while (num !=0);
average = (double) …Run Code Online (Sandbox Code Playgroud) 函数代码中似乎存在问题,因为函数无法运行之后的所有内容。
我通过conversion在2个函数中为变量赋予值并返回该值来对其进行测试。当时行得通。
function celsius(input) { /*convert to Celsius*/
var conversion = 5;
/*conversion = (5.0 / 9.0) * (input – 32);*/
return conversion;
}
Run Code Online (Sandbox Code Playgroud)
这是实际的代码。当我运行它时,什么也没有发生。我必须在函数中使用parseFloat吗?
function celsius(input) { /*convert to Celsius*/
var conversion;
conversion = (5.0 / 9.0) * (input – 32);
return conversion;
}
function fahrenheit(input) { /*convert to Fahrenheit*/
var conversion;
conversion = (9.0 / 5.0) * (input + 32);
return conversion;
}
var temp; /*temperature that will be converted*/
temp = parseFloat(prompt("Enter a temperature to …Run Code Online (Sandbox Code Playgroud) java ×2
javascript ×2
character ×1
converter ×1
directory ×1
mkdir ×1
shell ×1
temperature ×1
while-loop ×1