السلام عليكم
انا احتاج مساعده في هذا الكود اريد انا اقراء ثلاثة(وهي عبارة عن طول اضلاع مثلث) ارقم من ملف وتحويله من string الى integer ومن ثم ادخال الثلاثة ارقم الى method لعمل مقارنة وطباعة(نوع المثلث) الناتج
ولكن البرنامج لايعطيني اي نيجة وهذا الكود ومشكورين
طرقة كتابة الارقام في الملف
10 10 10
1 3 4
2 4 5
6 6 12
import B102.*;
class Triangle
{
public static void main(String args[])
{
String del="",triType="";
triType=GetNum();
PrintResults(triType);
return;
}
public static String GetNum()
{
textFile dFile;
int line1,line2,line3;
String triType="";
dFile = new textFile("data.txt", 'r');
while(!dFile.EOF())
{
line1 = dFile.readInt();
line2 = dFile.readInt();
line3 = dFile.readInt();
triType=(ProTriangle(line1,line2,line3));
}
dFile.closeFile();
return(triType);
}
public static String ProTriangle(int a,int b,int c)
{
String triType;
int sum_ab, sum_bc,sum_ac;
sum_ab = a+b;
sum_bc = b+c;
sum_ac = a+c;
if ((sum_ab > c) && (sum_bc > a) && (sum_ac > B))
{
if ((a==B) && (b==c))
triType = "equilateral triangle";
else
if ((a==B)||(b==c)||(c==a))
triType = "isosceles triangle";
else
triType = "scalene triangle";
}
else
triType = "Invalid triangle";
return(triType);
}
public static void PrintResults(String triType)
{
Screen.out.print(triType);
return;
}