JavaÀàÇó½âÒ»Ôª¶þ´Î·½³ÌµÄ¸ù
Ù¡Ç¿ http://blog.csdn.net/microtong
OakCMSÄÚÈݹÜÀíϵͳ http://www.oakcms.cn http://www.oakcms.net
Ò»Ôª¶þ´Î·½³Ìax2+bx+c=0£¬ÊäÈëa,b,cÈý¸öϵÊý£¬Çó½â·½³Ì£¬½á¹ûÓÐÈýÖÖÇé¿ö£ºÁ½¸öʵÊý¸ù¡¢Ò»¸öʵÊý¸ù¡¢Á½¸ö¸´Êý¸ù¡£
/**
* Equation.java
*/
package cn.edu.uibe.oop;
/**
* ¼ÆËãÒ»Ôª¶þ´Î·½³ÌµÄ¸ù
* @author TongQiang
*
*/
public class Equation {
double a,b,c; //·½³ÌµÄϵÊý
double x1,x2; //Á½¸ö¸ù
double r; //ʵ²¿
double v; //Ð鲿
int type; //0±íʾһ¸ö¸ù£¬1±íʾÁ½¸öʵ¸ù£¬2±íʾÁ½¸ö¸´ÊýµÄ¸ù
public Equation(double a,double b,double c){
this.a = a;
this.b = b;
this.c = c;
}
private double delta(){
return b*b-4*a*c;
}
public void calculate(){
double d = delta();
if(Math.abs(d) < 1E-5){
type = 0;
x1 = -b/(2*a);
x2 = x1;
}else if(d > 0){
type = 1;
x1 = (-b+Math.sqrt(d))/(2*a);
x2 = (-b-Math.sqrt(d))/(2*a);
}else{
type = 2;
r = -b/(2*a);
v = Math.sqrt(-d)/(2*a);
}
}
public void showResult(){
switch(type){
case 0:
System.out.println("·½³ÌÖ»ÓÐÒ»¸öʵ¸ù£¬x1=x2="+x1);
break;
case 1:
System.out.println("·½³ÌÓÐÁ½¸öʵ¸ù£¬·Ö±ðÊÇ£ºx1="+x1+"\tx2="+x2);
break;
case 2:
System.out.println("·½³ÌÓÐÁ½¸ö¸´Êý¸ù£¬·Ö±ðÊÇ£º"+r+"+"+v+"i,\t"+r+"-"+v+"i");
break;
}
}
public static void main(String[] args) {
Equation eq1 = new Equation(1,2,2);
eq1.calculate();
eq1.showResult();
&nbs
Ïà¹ØÎĵµ£º
xmlÎļþ£º
Xml´úÂë
<?xml version="1.0" encoding="GB2312"?>
<RESULT>
<VALUE>¡¡¡¡
<NO>A1234</NO>¡¡¡¡
<ADDR>ºÓÄÏÊ¡Ö£ÖÝÊÐ</ADDR>
</VALUE>&nbs ......
¡¡1¡¢JavaÓïÑÔÊǼòµ¥µÄ¡£JavaÓïÑÔµÄÓï·¨ÓëCÓïÑÔºÍC++ÓïÑԺܽӽü£¬Ê¹µÃ´ó¶àÊý³ÌÐòÔ±ºÜÈÝÒ×ѧϰºÍʹÓÃJava¡£ÁíÒ»·½Ã棬Java¶ªÆúÁËC++ ÖкÜÉÙʹÓõġ¢ºÜÄÑÀí½âµÄ¡¢ÁîÈËÃÔ»óµÄÄÇЩÌØÐÔ£¬Èç²Ù×÷·ûÖØÔØ¡¢¶à¼Ì³Ð¡¢×Ô¶¯µÄÇ¿ÖÆÀàÐÍת»»¡£ÌرðµØ£¬JavaÓïÑÔ²»Ê¹ÓÃÖ¸Õ룬²¢ÌṩÁË×Ô¶¯µÄ·ÏÁÏÊÕ¼¯£¬Ê¹µÃ³ÌÐòÔ±²»±ØΪÄÚ´æ¹ÜÀí¶øµ£ÓÇ¡£
¡¡¡ ......
public class Path {
//get class absolute address
public String getPath() {
String classPath = getClass().getName();
if (classPath.indexOf(".") != -1) {
classPath = classPath.substring(classPath.lastIndexOf(".") + 1,
......
ת×Ôwww.bitsCN.com
ÕªÒª£º±¾ÎÄ´ÓJavaÒì³£×î»ù±¾µÄ¸ÅÄî¡¢Óï·¨¿ªÊ¼½²ÊöÁËJavaÒì³£´¦ÀíµÄ»ù±¾ÖªÊ¶£¬·ÖÎöÁËJavaÒì³£Ìåϵ½á¹¹£¬¶Ô±ÈSpringµÄÒì³£´¦Àí¿ò
¼Ü£¬²ûÊöÁËÒì³£´¦ÀíµÄ»ù±¾ÔÔò¡£²¢ÇÒ×÷ÕßÌá³öÁË×Ô¼º´¦ÀíÒ»¸ö´óÐÍÓ¦ÓÃϵͳÒì³£µÄ˼Ï룬²¢Í¨¹ýÉè¼ÆÒ»¸öÒì³£´¦ÀíµÄ¿ò¼ÜÀ´ÂÛÊö´Ë˼Ïë¡£
Ò»¡¢ Òì³£µÄ¸ÅÄîº ......
Ò».¶Ñ:ÓÃnew¹Ø¼ü×Ö½¨Á¢,´æ·Å¶ÔÏóµÄÄÚÈÝ,GC¸ºÔð×Ô¶¯»ØÊÕ
ÄãÓÃÊ®¼¸¸öÂ齫ÅÆÊúÖ±µþ³ÉÒ»ÞûÕâ½Ð¶Ñ£¬Äã¿ÉÒÔ´ÓÉÏÃæ¡¢ÏÂÃæ¡¢ÖмäÈÎÒâ³é³öÒ»ÕÅÅÆ£¬Ò²¿ÉÒÔÈÎÒâ²åÈëÒ»ÕÅ¡£ËùÒԶѺÜÁé»î£¬µ«²»°²È«¡£¶ÔÓÚ¶ÔÏó£¬ÎÒÃÇÒª¶¯Ì¬µØ´´½¨¡¢Ïú»Ù£¬²»ÄÜ˵ºó´´½¨µÄ¶ÔÏóûÓÐÏú»Ù£¬ÏÈÇ°´´½¨µÄ¶ÔÏó¾Í²»ÄÜÏú»Ù£¬ÄÇÑùµÄ»°ÎÒÃǵijÌÐò¾Í´ç²½ÄÑÐУ¬ËùÒÔJavaÖ ......