Proposition => Write a program to calculate the slope if x1=x2 (Slope undefined)
Translated into Thailand => เขียนโปรแกรมที่ใช้คำนวนหาค่าความชัน เมื่อ x1=x2 ให้แสดงค่า(Slope undefined)
Solution=>
float m;
float x1=2, y1=5, x2=6, y2=8; //ประกาศตัวแปลชนิดจำนวนทศนิยม
void setup() {
if (x1==x2) {
println("Slope undefined.");
}
else {
m=(y2-y1)/(x2-x1); //ใช้ในการคำนวนหาค่าความชัน
println(m); //แสดงข้อความออกมาทางหน้าจอ
}
}
You can run code in http://processingjs.org/tools/processing-helper.html
text book name :Programming and problem solving with Java – 2nd edition
Author : Nell Dale and Chip Weems
ISBN 978-0-7637-3402-2
Translated into Thailand => เขียนโปรแกรมที่ใช้คำนวนหาค่าความชัน เมื่อ x1=x2 ให้แสดงค่า(Slope undefined)
Solution=>
float m;
float x1=2, y1=5, x2=6, y2=8; //ประกาศตัวแปลชนิดจำนวนทศนิยม
void setup() {
if (x1==x2) {
println("Slope undefined.");
}
else {
m=(y2-y1)/(x2-x1); //ใช้ในการคำนวนหาค่าความชัน
println(m); //แสดงข้อความออกมาทางหน้าจอ
}
}
You can run code in http://processingjs.org/tools/processing-helper.html
text book name :Programming and problem solving with Java – 2nd edition
Author : Nell Dale and Chip Weems
ISBN 978-0-7637-3402-2
ไม่มีความคิดเห็น:
แสดงความคิดเห็น