【問題】[J2EE] 有個簡單的問題想請問大大


Recommended Posts

我是一個大學生

最近學校開始教JAVA

前幾天出了一份作業,總共有兩題

第一題我寫出來了,很高興

但是第二題只寫出一半來

請大大幫忙指導一下,我是認為沒有錯阿,怎麼還不為給過?

題目是這樣

Write a program that inputs five numbers and determines and prints the number

of negative numbers input, the number of positive numbers input and the

number of zeros input.

我做的第一部份是

/**

* @(#)TEST2.java

*

* TEST2 application

*

* @author

* @version 1.00 2008/2/27

*/

import java.util.Scanner;

public class TEST2 {

public static void main(String[] args) {

Scanner input=new Scanner(System.in);

int number;

for(int i=1 ; i<=5 ; i++)

{

System.out.println("請輸入一個整數");

number = input.nextInt();

if(number>0)

{

System.out.println("你輸入的整數為正整數\n謝謝");

}

if (number<0)

{

System.out.println("你輸入的整數為負整數\n謝謝");

}

if (number==0)

{

System.out.println("你輸入的整數為零\n謝謝");

}

}

// TODO, add your application code

}

}

COMPILE給過了

可是加了第二部份,卻

/**

* @(#)TEST2.java

*

* TEST2 application

*

* @author

* @version 1.00 2008/2/27

*/

import java.util.Scanner;

public class TEST2 {

public static void main(String[] args) {

Scanner input=new Scanner(System.in);

int number;

int a=0,b=0,c=0;

for(int i=1 ; i<=5 ; i++)

{

System.out.println("請輸入一個整數");

number = input.nextInt();

if(number>0)

{

System.out.println("你輸入的整數為正整數\n謝謝");

++a;

}

if (number<0)

{

System.out.println("你輸入的整數為負整數\n謝謝");

++b;

}

if (number==0)

{

System.out.println("你輸入的整數為零\n謝謝");

++c;

}

}

System.out.println("你輸入了%d個正整數",a);

System.out.println("你輸入了%d個負整數",b);

System.out.println("你輸入了%d個零",c);

// TODO, add your application code

}

}

COMPILE卻不給過

反而出現了

cannot find symbol method println(java.lang.String,int) line37 38 39

COMPILE卻不給過

反而出現了

cannot find symbol method println(java.lang.String,int) line37 38 39

我不知道這句錯誤訊息是什麼意思,要如何修正呢?

謝謝

鏈接文章
分享到其他網站

請登入後來留意見

在登入之後,您才能留意見



立即登入