View Single Post
ישן 05-10-06, 16:20   # 1
CSite.co.il
משתמש - היכל התהילה
 
מיני פרופיל
תאריך הצטרפות: Oct 2005
הודעות: 1,816

CSite.co.il לא מחובר  

עזרה בהרצת קוד JAVA.

אני עובד עם eclipse, וכנראה ה - console לא עובד אצלי טוב.

הקוד הבא:
קוד:
import java.lang.Math;
import javax.swing.JOptionPane;

public class hello {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int a,b,c,m,f,f2,g,f3,f4;
		f = 0;
		a = Integer.parseInt(JOptionPane.showInputDialog("insert first number"));
		b = Integer.parseInt(JOptionPane.showInputDialog("insert sec number"));
		c = Integer.parseInt(JOptionPane.showInputDialog("insert third number"));
		m = ((b*b)* -(4)*(a*c));
		g = (int)Math.sqrt((double)m);
        
		
		if (g > 0)
		{
			f = (-b + g)/(2*a) ;
		    f2 = (-b - g)/(2*a);
		    System.out.print("the first result is");
		    System.out.print(f2);
		    System.out.print("the sec result is");
		    System.out.print(f);
		    System.out.print("the equation is positive");
		}
		if (g < 0)
		{
			f3 = (-b + g)/(2*a);
		    f4 = (-b - g)/(2*a);
		    System.out.print("the first result is");
		    System.out.print(f4);
		    System.out.print("the sec result is");
		    System.out.print(f3);
		    System.out.print("the equation is negative");
		    
		}
		}
	}
זה משוואה ריבועית... x12..

תודה לעוזרים!