大神幫我看看哪有問題
public class HelloWorld {
? ? public static void main(String[] args) {
int one = 20 ;
? ?duoble two =one%2;
? ?if(two=o){
? ? ? ?System.out.println("one是偶數(shù)");
?}
? ? ? ? else{
? ? ? ? ? ? System.out.println("one是奇數(shù)");
? ? ? ? }
}
}
2019-02-18
int one %=2;請(qǐng)問這有什么問題
2018-08-31
修改后的正確代碼如下:
2018-07-23
首先 有兩點(diǎn)問題
1:two==0 你寫的是 two=o(賦值語句 );
2:one 和 two 類型應(yīng)該是一樣的? 如果是one int 型? 那么 two也應(yīng)該是int型
因此我把代碼中的int two=one%2 改成了 double two=one%2.0
希望對(duì)你有幫助
2018-07-23
public class HelloWorld {
? ? public static void main(String[] args) {
double one = 20 ;
? double two =one%2.0;
? ?if(two==0){
? ? ? ?System.out.println("one是偶數(shù)");
?}
? ? ? ? else{
? ? ? ? ? ? System.out.println("one是奇數(shù)");
? ? ? ? }
}
}
2018-07-22
“=”是右邊的值賦給左邊的意思,“==”用于比較左右兩邊的值是否相等,所以應(yīng)該把“=”改成“==”;
還有,你的“two=o”右邊的o應(yīng)該不是數(shù)字0吧?要寫數(shù)字0呀~