::ภาษา JAVA::...++โปรแกรมรับค่าจากคีย์บอร์ด(JOptionPane)เพื่อแสดงปี พุทธศักราช++...
import javax.swing.JOptionPane; public class Addition3 { public static void main( String args[] ) { String number1; int x;
// read in number from user as a string Number1 = JOptionPane.showInputDialog( "Enter Number " );
// convert number from type String to type int x = Integer.parseInt( Number1 );
if ((x < 10) || (x > 9999)) //ใช้คำสั่ง if เปรียบเทียบจำนวนที่รับเข้ามาว่าอยู่นอกช่วง 10-9999 หรือไม่ { JOptionPane.showMessageDialog( null, "The year is not Valid " ); //เงื่อนไขเป็นจริง } else //เงื่อนไขเป็นเท็จ { if ((x < 10) || (x > 99)) //ใช้คำสั่ง if เปรียบเทียบจำนวนที่รับเข้ามาว่าอยู่นอกช่วง 10-99 หรือไม่ { JOptionPane.showMessageDialog( null, "Buddhist Era, " + x); //เงื่อนไขเป็นจริง } else { JOptionPane.showMessageDialog( null, "Buddhist Era, " + (x + 2000)); //เงื่อนไขเป็นเท็จ }
}
System.exit( 0 ); // terminate the program } }
หมายเหตุ มินใช้โปรแกรม EditPlus v. 3.0 เขียนนะคะ
Create Date : 30 มิถุนายน 2551 |
|
1 comments |
Last Update : 30 มิถุนายน 2551 18:41:26 น. |
Counter : 2747 Pageviews. |
|
|
|
ป่าน ป่าน ป่าน ป่าน
ป่าน ป่าน ป่าน
ป่าน ป่าน
ป่าน ป่าน
ป่าน ป่าน
ป่าน ป่าน
ป่าน าน
ป่าน ป่าน
ป่าน ป่าน
ป่าน ป่าน
ป่านป่าน
ป่าน