SlideShare a Scribd company logo
1 of 19
Download to read offline
การสร้างโปรแกรมคานวณดัชนีมวลกาย
       (BMI) ด้วยภาษา JAVA
สมาชิกในกลุม
                                                                                              ่
FACULTY OF EDUCATION KHONKAEN UNIVERSITY
                            PROGRAMIMNG FOR TEACHERS




                                                       น.ส. ชัญญกัญญา ทิพย์รักษ์                  น.ส.อาภาภรณ์ นิลคีรี
                                                       น.ส. ฐิดารัตน์ ชื่นธงชัย                   น.ส. พิมงาม มัดหา
                                                       นายกฤษณะ คาพิระ                            นายประสาน ไปใหม่
ภารกิจการเรียนรู้
FACULTY OF EDUCATION KHONKAEN UNIVERSITY




                                                        โปรแกรมคานวณดัชนีมวลกาย (BMI)
                            PROGRAMIMNG FOR TEACHERS




                                                           เด็กชายต้นไม้เพื่อนร่วมชั้นของนักเรียน มีอายุ 14 ขวบ น้้าหนัก 68
                                                       ส่วนสูง 172 เด็กชายต้นไม้มีความกังวลว่าตัวเองไม่สมส่วนตามมาตรฐาน
                                                       BMI ในฐานะที่นักเรียนเป็นเพื่อนร่วมชั้นของเด็กชายต้นไม้จึงอยากให้
                                                       นักเรียนช่วยกันเขียนโปรแกรมเพื่อช่วยในการค้านวณหาค่ามาตรฐาน
                                                       BMI ด้วยภาษาจาวาอย่างง่าย โดยแบ่งกลุ่มกลุมละ3คน เพื่อท้าภารกิจนี้
                                                                                                     ่
                                                       ให้ส้าเร็จ
คาสั่ง IF
FACULTY OF EDUCATION KHONKAEN UNIVERSITY
                            PROGRAMIMNG FOR TEACHERS



                                                       1. IF แบบ 1 เงื่อนไข (IF)

                                                                              โดยเงื่อนไขในวงเล็บนั้นจะเป็นประโยค
                                                                             ทางตรรก ถ้าตรวจสอบแล้วเป็นจริงก็จะเข้า
                                                                             มาท้างานในกลุ่มค้าสั่งที่เราก้าหนด ไว้ใน
                                                                             ขอบเขตของเครื่องหมายปีกกา แต่ถ้าเป็น
                                                                             เท็จก็จะข้ามไปท้าส่วนต่อไปของโปรแกรม
                                                                             ทันทีตามภาพ
คาสั่ง IF
FACULTY OF EDUCATION KHONKAEN UNIVERSITY




                                                       2. IF แบบ 2 เงื่อนไข (IF…ELSE)
                            PROGRAMIMNG FOR TEACHERS




                                                                     เป็นคาสั่งเพื่อการตัดสินใจ 2 เงื่อนไข
                                                       แบบที่ 1
                                                       If (เงื่อนไข)                                                             เท็จ
                                                       {                                                    เงื่อนไข
                                                         ประโยคคาสั่งต่างๆ เมื่อเงื่อนไขเป็นจริง;
                                                                                                                         จริง
                                                       }
                                                       Else                                                 ค้าสั่งต่างๆ เมื่อ          ค้าสั่งต่างๆ เมื่อ
                                                       {                                                    เงื่อนไขเป็นจริง            เงื่อนไขเป็นเท็จ
                                                         ประโยคคาสั่งต่างๆเมือเงือนไขเป็นเท็จ;
                                                                             ่ ่
                                                       }
                                                         คาสั่งอื่นๆ;                                       ค้าสั่งถัดไป
คาสั่ง IF
FACULTY OF EDUCATION KHONKAEN UNIVERSITY
                            PROGRAMIMNG FOR TEACHERS



                                                              แบบที่ 2                                     Start

                                                       If (เงื่อนไข)
                                                       {                                                  เงื่อนไข
                                                         ประโยคคาสั่งต่างๆ ชุดที่ 1;
                                                       }                                     คำสังที่ 1
                                                                                                 ่
                                                       Else
                                                                                                                     คำสังที่ 2
                                                                                                                         ่
                                                       {
                                                         ประโยคคาสั่งต่างๆ ชุดที่สอง;
                                                       }
                                                         คาสั่งอื่นๆ;
                                                                                                          Stop
Do while
FACULTY OF EDUCATION KHONKAEN UNIVERSITY




                                                       ค้าสั่ง do while จะเห็นได้ว่าไม่มีการเช็คเงื่อนไขก่อนว่าเป็นจริงหรือเท็จ จะท้าค้าสั่ง
                            PROGRAMIMNG FOR TEACHERS



                                                       ต่างๆ ที่ do ก่อน 1 ครั้ง พอจบการท้าที่ do แล้วจึงมาเช็คเงื่อนไขที่ while ที่อยู่
                                                       ด้านล่าง
Dialog
FACULTY OF EDUCATION KHONKAEN UNIVERSITY




                                                       การใช้คาสั่ง JOptionPane.showMessageDialog
                            PROGRAMIMNG FOR TEACHERS




                                                       เป็นค้าสั่งทีแสดงผลการตอบสนองกับ User ที่ใช้งานในระบบของเราที่ออกมาใน
                                                                    ่
                                                       รูปแบบของหน้าต่าง (Dialog)
                                                       import javax.swing.JOptionPane;
                                                       public class DialogViewer {
                                                       public static void main(String[] args){
                                                       JOptionPane.showMessageDialog(null,”Hello World”);
                                                       }
                                                       }
Dialog

              ผลการตอบสนองของโปรแกรม
           PROGRAMIMNG FOR TEACHERS
     FACULTY OF EDUCATION KHONKAEN UNIVERSITY
Dialog
FACULTY OF EDUCATION KHONKAEN UNIVERSITY




                                                       คุณสมบัตพิเศษ
                                                               ิ
                            PROGRAMIMNG FOR TEACHERS




                                                             1.รับข้อมูลเป็นแบบหน้าต่าง
                                                             2. สามารถแสดงข้อมูลเป็นภาษาไทยได้
Code BMI
      PROGRAMIMNG FOR TEACHERS
FACULTY OF EDUCATION KHONKAEN UNIVERSITY
Code BMI
FACULTY OF EDUCATION KHONKAEN UNIVERSITY




                                                       อยู่ในคลาสที่ชื่อว่า JOptionPane ซึ่งคลาสนี้อยู่ในแพ็กเก็ต
                            PROGRAMIMNG FOR TEACHERS




                                                                    (Package) ที่ชื่อว่า javax.swing




                                                        กาหนดตัวแปรต่างๆ ที่จะใช้ในการทางานของโปรแกรม
3
                 2
               1




                                    2
Code BMI




                                                      3
                                               1
                 PROGRAMIMNG FOR TEACHERS
           FACULTY OF EDUCATION KHONKAEN UNIVERSITY
Code BMI
                 PROGRAMIMNG FOR TEACHERS
           FACULTY OF EDUCATION KHONKAEN UNIVERSITY
Code BMI
                 PROGRAMIMNG FOR TEACHERS
           FACULTY OF EDUCATION KHONKAEN UNIVERSITY
Start
                                                                                         Flowchart Code
                                                                  weight = 0,
                                                                  height = 0,                 BMI
FACULTY OF EDUCATION KHONKAEN UNIVERSITY




                                                               number1 = weight,
                                                               number2 = height,
                            PROGRAMIMNG FOR TEACHERS



                                                            number3 = (number2/100)



                                                                กรอกชื่อ

                                                                กรอกส่วนสูง

                                                                กรอกน ้ำหนัก

                                                       BMI = number1/(number3*number3)
YES
                                                       น ้ำหนักต่ำกว่ำมำตรฐำน         BMI < 18.5
FACULTY OF EDUCATION KHONKAEN UNIVERSITY




                                                                                               NO
                                                                                YES
                            PROGRAMIMNG FOR TEACHERS



                                                       อยู่ในเกณฑ์มำตรฐำน                BMI
                                                                                        <=22.9

                                                                                              NO
                                                                                YES      BMI
                                                          อ้ วนระดับ 1
                                                                                        <=24.9
                                                                                               NO
                                                                                YES
                                                           อ้ วนระดับ 2                  BMI
                                                                                        <=29.9
                                                                                              NO
                                                                                      อ้ วนระดับ 3
คุณต้ องกำรใช้ งำนโปรแกรม
FACULTY OF EDUCATION KHONKAEN UNIVERSITY




                                                             ต่อหรื อไม่ (Y/N)
                            PROGRAMIMNG FOR TEACHERS




                                                            Cont = “Y” YES         Check = true
                                                             && “y”
                                                                    NO
                                                          Check = false

                                                               Finish
Thank You!     เข้าไปประเมินการสอนได้ที่..
https://docs.google.com/forms/d/1M1S3ZQMLGAuleQlfWr7m
         AKbH0J0wIqEnZK_SjkXiL6w/viewform?pli=1

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Java bmi Code

  • 2. สมาชิกในกลุม ่ FACULTY OF EDUCATION KHONKAEN UNIVERSITY PROGRAMIMNG FOR TEACHERS น.ส. ชัญญกัญญา ทิพย์รักษ์ น.ส.อาภาภรณ์ นิลคีรี น.ส. ฐิดารัตน์ ชื่นธงชัย น.ส. พิมงาม มัดหา นายกฤษณะ คาพิระ นายประสาน ไปใหม่
  • 3. ภารกิจการเรียนรู้ FACULTY OF EDUCATION KHONKAEN UNIVERSITY โปรแกรมคานวณดัชนีมวลกาย (BMI) PROGRAMIMNG FOR TEACHERS เด็กชายต้นไม้เพื่อนร่วมชั้นของนักเรียน มีอายุ 14 ขวบ น้้าหนัก 68 ส่วนสูง 172 เด็กชายต้นไม้มีความกังวลว่าตัวเองไม่สมส่วนตามมาตรฐาน BMI ในฐานะที่นักเรียนเป็นเพื่อนร่วมชั้นของเด็กชายต้นไม้จึงอยากให้ นักเรียนช่วยกันเขียนโปรแกรมเพื่อช่วยในการค้านวณหาค่ามาตรฐาน BMI ด้วยภาษาจาวาอย่างง่าย โดยแบ่งกลุ่มกลุมละ3คน เพื่อท้าภารกิจนี้ ่ ให้ส้าเร็จ
  • 4. คาสั่ง IF FACULTY OF EDUCATION KHONKAEN UNIVERSITY PROGRAMIMNG FOR TEACHERS 1. IF แบบ 1 เงื่อนไข (IF) โดยเงื่อนไขในวงเล็บนั้นจะเป็นประโยค ทางตรรก ถ้าตรวจสอบแล้วเป็นจริงก็จะเข้า มาท้างานในกลุ่มค้าสั่งที่เราก้าหนด ไว้ใน ขอบเขตของเครื่องหมายปีกกา แต่ถ้าเป็น เท็จก็จะข้ามไปท้าส่วนต่อไปของโปรแกรม ทันทีตามภาพ
  • 5. คาสั่ง IF FACULTY OF EDUCATION KHONKAEN UNIVERSITY 2. IF แบบ 2 เงื่อนไข (IF…ELSE) PROGRAMIMNG FOR TEACHERS เป็นคาสั่งเพื่อการตัดสินใจ 2 เงื่อนไข แบบที่ 1 If (เงื่อนไข) เท็จ { เงื่อนไข ประโยคคาสั่งต่างๆ เมื่อเงื่อนไขเป็นจริง; จริง } Else ค้าสั่งต่างๆ เมื่อ ค้าสั่งต่างๆ เมื่อ { เงื่อนไขเป็นจริง เงื่อนไขเป็นเท็จ ประโยคคาสั่งต่างๆเมือเงือนไขเป็นเท็จ; ่ ่ } คาสั่งอื่นๆ; ค้าสั่งถัดไป
  • 6. คาสั่ง IF FACULTY OF EDUCATION KHONKAEN UNIVERSITY PROGRAMIMNG FOR TEACHERS แบบที่ 2 Start If (เงื่อนไข) { เงื่อนไข ประโยคคาสั่งต่างๆ ชุดที่ 1; } คำสังที่ 1 ่ Else คำสังที่ 2 ่ { ประโยคคาสั่งต่างๆ ชุดที่สอง; } คาสั่งอื่นๆ; Stop
  • 7. Do while FACULTY OF EDUCATION KHONKAEN UNIVERSITY ค้าสั่ง do while จะเห็นได้ว่าไม่มีการเช็คเงื่อนไขก่อนว่าเป็นจริงหรือเท็จ จะท้าค้าสั่ง PROGRAMIMNG FOR TEACHERS ต่างๆ ที่ do ก่อน 1 ครั้ง พอจบการท้าที่ do แล้วจึงมาเช็คเงื่อนไขที่ while ที่อยู่ ด้านล่าง
  • 8. Dialog FACULTY OF EDUCATION KHONKAEN UNIVERSITY การใช้คาสั่ง JOptionPane.showMessageDialog PROGRAMIMNG FOR TEACHERS เป็นค้าสั่งทีแสดงผลการตอบสนองกับ User ที่ใช้งานในระบบของเราที่ออกมาใน ่ รูปแบบของหน้าต่าง (Dialog) import javax.swing.JOptionPane; public class DialogViewer { public static void main(String[] args){ JOptionPane.showMessageDialog(null,”Hello World”); } }
  • 9. Dialog ผลการตอบสนองของโปรแกรม PROGRAMIMNG FOR TEACHERS FACULTY OF EDUCATION KHONKAEN UNIVERSITY
  • 10. Dialog FACULTY OF EDUCATION KHONKAEN UNIVERSITY คุณสมบัตพิเศษ ิ PROGRAMIMNG FOR TEACHERS 1.รับข้อมูลเป็นแบบหน้าต่าง 2. สามารถแสดงข้อมูลเป็นภาษาไทยได้
  • 11. Code BMI PROGRAMIMNG FOR TEACHERS FACULTY OF EDUCATION KHONKAEN UNIVERSITY
  • 12. Code BMI FACULTY OF EDUCATION KHONKAEN UNIVERSITY อยู่ในคลาสที่ชื่อว่า JOptionPane ซึ่งคลาสนี้อยู่ในแพ็กเก็ต PROGRAMIMNG FOR TEACHERS (Package) ที่ชื่อว่า javax.swing กาหนดตัวแปรต่างๆ ที่จะใช้ในการทางานของโปรแกรม
  • 13. 3 2 1 2 Code BMI 3 1 PROGRAMIMNG FOR TEACHERS FACULTY OF EDUCATION KHONKAEN UNIVERSITY
  • 14. Code BMI PROGRAMIMNG FOR TEACHERS FACULTY OF EDUCATION KHONKAEN UNIVERSITY
  • 15. Code BMI PROGRAMIMNG FOR TEACHERS FACULTY OF EDUCATION KHONKAEN UNIVERSITY
  • 16. Start Flowchart Code weight = 0, height = 0, BMI FACULTY OF EDUCATION KHONKAEN UNIVERSITY number1 = weight, number2 = height, PROGRAMIMNG FOR TEACHERS number3 = (number2/100) กรอกชื่อ กรอกส่วนสูง กรอกน ้ำหนัก BMI = number1/(number3*number3)
  • 17. YES น ้ำหนักต่ำกว่ำมำตรฐำน BMI < 18.5 FACULTY OF EDUCATION KHONKAEN UNIVERSITY NO YES PROGRAMIMNG FOR TEACHERS อยู่ในเกณฑ์มำตรฐำน BMI <=22.9 NO YES BMI อ้ วนระดับ 1 <=24.9 NO YES อ้ วนระดับ 2 BMI <=29.9 NO อ้ วนระดับ 3
  • 18. คุณต้ องกำรใช้ งำนโปรแกรม FACULTY OF EDUCATION KHONKAEN UNIVERSITY ต่อหรื อไม่ (Y/N) PROGRAMIMNG FOR TEACHERS Cont = “Y” YES Check = true && “y” NO Check = false Finish
  • 19. Thank You! เข้าไปประเมินการสอนได้ที่.. https://docs.google.com/forms/d/1M1S3ZQMLGAuleQlfWr7m AKbH0J0wIqEnZK_SjkXiL6w/viewform?pli=1