-3
我需要在這問一個循環,詢問玩家是否想再次玩。如果用戶說是的重新啓動遊戲。如果他們說不結束比賽。我一起遇到麻煩。請幫忙!循環出現問題
import java.util.Scanner;
public class HW4ChrisMuncher
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
double a;
int b;
System.out.println("Enter a number");
double userNum = input.nextDouble();
a = userNum;
Scanner input2 = new Scanner(System.in);
System.out.println("Enter a number (no decimals!)");
int userNum2 = input2.nextInt();
b = userNum2;
double c = min(a, b);
double d = max(a, b);
double e = abs(a);
double f = pow(a, b);
System.out.println("The minimum value of " + a + " and " + b + " is " + c);
System.out.println("The maximum value of " + a + " and " + b + " is " + d);
System.out.println("The absolute value of "+ a+ " is " + e);
System.out.println(+ a + " to the power of " + b + " is " + f);
}
// Returns the minimum of two numbers
public static double min(double n1, int n2)
{
double min;
if (n1 > n2)
min = n2;
else
min = n1;
return min;
}
// Return the max between two numbers
public static double max(double n1, int n2)
{
double max;
if (n1 > n2)
max = n1;
else
max = n2;
return max;
}
//Returns the absolute value of the two numbers
public static double abs(double n1)
{
if (n1 < 0)
return -n1;
else
return n1;
}
public static double pow(double n1, int n2)
{
double f = 1;
for (int i =0; i< n2; i++)
{
f = f * n1;
}
return f;
}
}
你的問題是什麼? – Qix 2014-10-29 00:52:49
我需要幫助把這個循環放在這個 – 2014-10-29 00:53:33
什麼循環?您沒有提供任何描述性信息,說明您面臨的問題。你有什麼嘗試?你收到什麼錯誤?你不明白什麼? – Qix 2014-10-29 00:54:20