السلام عليكم ...
الأخوة الأعزاء .. أنا بحاول أعمل test class لل method باستخدام ال Scanner و لكن يطلع لي هذا ال error
D:\......................................GCD.java:2: cannot resolve symbol
symbol : class Scanner
location: package util
import java.util.Scanner;
^
D:\.....................................GCD.java:53: cannot resolve symbol
symbol : class Scanner
location: class GCD
Scanner sc = new Scanner (System.in);
^
D:\......................................GCD.java:53: cannot resolve symbol
symbol : class Scanner
location: class GCD
Scanner sc = new Scanner (System.in);
^
3 errors
Process completed.
و هذا هو الكود ....
import java.util.Scanner;
public class GCD
{
public static int gcd(int n, int k)
{
int r; // the remainder
r = n % k;
if (r == 0)
return k;
else
return gcd(k, r);
}
public static void main(String[] args)
{
Scanner sc = new Scanner (System.in);
System.out.print("Enter the first integer: ");
int first = sc.nextInt();
System.out.print("Enter the second integer: ");
int second = sc.nextInt();
int Gcd = gcd(first, second);
System.out.println("the greatest common divisor = "+Gcd);
}
}مع العلم إنى عرفت أسوي ال test class باستخدام ال BufferedReader
و دمتم ...