công cộng lớp BodyMassApplet mở rộng tiểu dụng thực hiện ActionListener {//declare variablesImage biểu tượng; //declare một hình ảnh objectint inch, cân Anh;đôi mét, kg, chỉ số;xây dựng componentsLabel companyLabel = mới nhãn ("THE SUN thể dục trung tâm BODY MASS INDEX CALCULATOR"); Nhãn heightLabel = nhãn mới ("Enter chiều cao của bạn đến gần nhất inch"); TextField heightField = mới TextField(10); Nhãn weightLabel = nhãn mới ("Enter trọng lượng của bạn đến gần nhất pound"); TextField weightField = mới TextField(10); Nút calcButton = mới Button("Calculate"); Nhãn outputLabel = nhãn mới ("Click vào nút tính toán để xem chỉ số khối lượng cơ thể của bạn.");inch = Integer.parseInt(heightField.getText()); Pound = Integer.parseInt(weightField.getText()); m = inch / 39.36;kg = pounds / 2.2; chỉ mục = kg / Math.pow (mét, 2); outputLabel.setText ("Bạn BODY MASS INDEX IS" + Math.round(index) + ".");}khu vực vô hiệu paint(Graphics g) {g.drawImage(logo,125,160,this);
đang được dịch, vui lòng đợi..
