ช่วยหน่อยครับ !!! เขียน Java บน eclipse มีโจทย์??
Moderators: mindphp, ผู้ดูแลกระดาน
-
- PHP Newbie
- Posts: 4
- Joined: 09/01/2012 5:19 pm
ช่วยหน่อยครับ !!! เขียน Java บน eclipse มีโจทย์??
ช่วยหน่อยครับ !!! เขียน Java บน eclipse มีโจทย์??
1) เขียนโปรแกรมหาค่า x จากสมการ ax ยกกำลัง 2 + bx + c = 0
โดยรับค่า a, b และ c ผ่านทาง command line และให้แสดงผลลัพท์ออกทางจกภาพ
2) เขียนโปรแกรมหาค่าเส้นผ่านศูนย์กลางวงกลมจากสมการ 2TTr (สองพายอาร์)
โดนรับค่า r ผ่านทาง command line และให้แสดงผลลัพท์ออกทางจอภาพ ( TT = 22/7) <=(พาย = 22หาร7)
3) เขียนโปรแกรม โดยนำหลักการมาจากไพ่ ป๊อกเด้ง โดยให้แสดงค่าของไพ่ที่ได้รับมา 2 ใบจากหน้าจอ
โดยหากได้ค่าเป็น 8 หรือ 9 ให้ print แสดงค่า "POK" ออกมาทางจอภาพด้วย
ช่วยกันหน่อยน๊ะครับ T^T
1) เขียนโปรแกรมหาค่า x จากสมการ ax ยกกำลัง 2 + bx + c = 0
โดยรับค่า a, b และ c ผ่านทาง command line และให้แสดงผลลัพท์ออกทางจกภาพ
2) เขียนโปรแกรมหาค่าเส้นผ่านศูนย์กลางวงกลมจากสมการ 2TTr (สองพายอาร์)
โดนรับค่า r ผ่านทาง command line และให้แสดงผลลัพท์ออกทางจอภาพ ( TT = 22/7) <=(พาย = 22หาร7)
3) เขียนโปรแกรม โดยนำหลักการมาจากไพ่ ป๊อกเด้ง โดยให้แสดงค่าของไพ่ที่ได้รับมา 2 ใบจากหน้าจอ
โดยหากได้ค่าเป็น 8 หรือ 9 ให้ print แสดงค่า "POK" ออกมาทางจอภาพด้วย
ช่วยกันหน่อยน๊ะครับ T^T
- mindphp
- ผู้ดูแลระบบ MindPHP
- Posts: 26692
- Joined: 22/09/2008 6:18 pm
- Contact:
Re: ช่วยหน่อยครับ !!! เขียน Java บน eclipse มีโจทย์??
โจทย์การบ้านแนะนำให้ลองทำดูเองก่อน ดีกว่าครับ
ติดปัญหา ตรงไหนค่อยมาถาม
จะได้ผึกตัวเองไปด้วยครับ
ติดปัญหา ตรงไหนค่อยมาถาม
จะได้ผึกตัวเองไปด้วยครับ
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
-
- PHP Newbie
- Posts: 4
- Joined: 09/01/2012 5:19 pm
Re: ช่วยหน่อยครับ !!! เขียน Java บน eclipse มีโจทย์??
ข้อ 1) import java.util.Scanner;
public class Find_x {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
System.out.println("Input a : ");
String vala =in.nextLine();
System.out.println("Input b : ");
String valb =in.nextLine();
System.out.println("Input c : ");
String valc =in.nextLine();
int a = Integer.parseInt(vala); /**a = 1 **/
int b = Integer.parseInt(valb); /**b = -6 **/
int c = Integer.parseInt(valc); /**c = 8 **/
//System.out.println("The algorithm is " + a + "x*x + " + b + "x + " + c + " = 0");
doCalculate(a, b, c);
}
public static void doCalculate(int a, int b, int c){
double Root = Math.sqrt(b*b - (4*a*c));
double valplus = ((-b) + Root)/(2*a);
double valminus = ((-b) - Root)/(2*a);
System.out.println("The value of x is " + valplus);
System.out.println("The value of x is " + valminus);
}
}
อย่างนี้ สมบูรณ์หรือยังครับ หรือต้องแก้ไขตรงไหนบ้าง???
public class Find_x {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
System.out.println("Input a : ");
String vala =in.nextLine();
System.out.println("Input b : ");
String valb =in.nextLine();
System.out.println("Input c : ");
String valc =in.nextLine();
int a = Integer.parseInt(vala); /**a = 1 **/
int b = Integer.parseInt(valb); /**b = -6 **/
int c = Integer.parseInt(valc); /**c = 8 **/
//System.out.println("The algorithm is " + a + "x*x + " + b + "x + " + c + " = 0");
doCalculate(a, b, c);
}
public static void doCalculate(int a, int b, int c){
double Root = Math.sqrt(b*b - (4*a*c));
double valplus = ((-b) + Root)/(2*a);
double valminus = ((-b) - Root)/(2*a);
System.out.println("The value of x is " + valplus);
System.out.println("The value of x is " + valminus);
}
}
อย่างนี้ สมบูรณ์หรือยังครับ หรือต้องแก้ไขตรงไหนบ้าง???
-
- PHP Newbie
- Posts: 4
- Joined: 09/01/2012 5:19 pm
Re: ช่วยหน่อยครับ !!! เขียน Java บน eclipse มีโจทย์??
2)import java.util.Scanner;
public class Find_d {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
System.out.println("Input r : ");
String valr =in.nextLine();
int r = Integer.parseInt(valr); /**r = 14 **/
doCalculate (r);
}
public static void doCalculate(int r){
float d = (22f/7f)*2*r;
System.out.println("The Circle d length is " + d);
}
}
ช่วยตรวจสอบหน่อยน๊ะ ไม่แน่ใจ??
public class Find_d {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
System.out.println("Input r : ");
String valr =in.nextLine();
int r = Integer.parseInt(valr); /**r = 14 **/
doCalculate (r);
}
public static void doCalculate(int r){
float d = (22f/7f)*2*r;
System.out.println("The Circle d length is " + d);
}
}
ช่วยตรวจสอบหน่อยน๊ะ ไม่แน่ใจ??
-
- PHP Newbie
- Posts: 4
- Joined: 09/01/2012 5:19 pm
Re: ช่วยหน่อยครับ !!! เขียน Java บน eclipse มีโจทย์??
3)import java.util.Random;
import java.util.Scanner;
public class POK {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
System.out.println("Type P1 to random first card");
String val1 =in.nextLine();
double ran1 = (Math.random()*10);
int card1 = (int)ran1;
double ran2 = (Math.random()*10);
int card2 = (int)ran2;
if(val1.equals("P1")){
System.out.println("Card 1 is " + card1);
}else{
return;
}
System.out.println("Type P2 to random second card");
String val2 =in.nextLine();
if(val2.equals("P2")){
System.out.println("Card 2 is " + card2);
}else{
return;
}
int sum = card1 + card2;
int result = sum % 10;
if(result == 8 || result == 9){
System.out.println(result);
System.out.println("POK");
}else{
System.out.println(result);
}
}
}
จะส่งในอีกไม่กี่วันแล้ว T^T??
import java.util.Scanner;
public class POK {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
System.out.println("Type P1 to random first card");
String val1 =in.nextLine();
double ran1 = (Math.random()*10);
int card1 = (int)ran1;
double ran2 = (Math.random()*10);
int card2 = (int)ran2;
if(val1.equals("P1")){
System.out.println("Card 1 is " + card1);
}else{
return;
}
System.out.println("Type P2 to random second card");
String val2 =in.nextLine();
if(val2.equals("P2")){
System.out.println("Card 2 is " + card2);
}else{
return;
}
int sum = card1 + card2;
int result = sum % 10;
if(result == 8 || result == 9){
System.out.println(result);
System.out.println("POK");
}else{
System.out.println(result);
}
}
}
จะส่งในอีกไม่กี่วันแล้ว T^T??
-
- PHP Super Member
- Posts: 480
- Joined: 25/01/2010 11:57 pm
- Contact:
Re: ช่วยหน่อยครับ !!! เขียน Java บน eclipse มีโจทย์??
คำตอบมันออกมาได้ก็คือได้ครับ คุณจะไม่แน่ใจได้ยังไง ถ้าทดลองแล้วคำตอบมันไม่ตรงก็แสดงว่าไม่ได้
-
- Similar Topics
- Replies
- Views
- Last post
-
-
ช่วยหน่อยครับ โจทย์ เขียนโปรแกรม Eclipse java
by yamahacyber » 20/09/2014 1:42 pm » in Microsoft Office Knowledge & line & Etc - 0 Replies
- 985 Views
-
Last post by yamahacyber
20/09/2014 1:42 pm
-
-
-
ช่วยหน่อยครับ โจทย์ เขียนโปรแกรม Eclipse java
by yamahacyber » 20/09/2014 1:43 pm » in Programming - C/C++ & java & Python - 0 Replies
- 1090 Views
-
Last post by yamahacyber
20/09/2014 1:43 pm
-
-
-
แนวข้อสอบ เขียนโปรแกรม Eclipse java
by yamahacyber » 20/09/2014 1:48 pm » in Programming - C/C++ & java & Python - 0 Replies
- 1548 Views
-
Last post by yamahacyber
20/09/2014 1:48 pm
-
-
-
!!ขอความช่วยเหลือหน่อยงับ เขียน Java ในโปรแกรม Eclip
by outneszx » 15/10/2012 6:29 pm » in Programming - C/C++ & java & Python - 0 Replies
- 1470 Views
-
Last post by outneszx
15/10/2012 6:29 pm
-
-
-
รู้จักคีย์ลัดบน Eclipse (อีคลิปส์)
by Wallapa » 01/11/2017 5:55 pm » in Mobile Application Developing- Android, iOS - 0 Replies
- 931 Views
-
Last post by Wallapa
01/11/2017 5:55 pm
-
-
- 3 Replies
- 3238 Views
-
Last post by mindphp
16/12/2017 4:04 pm
Who is online
Users browsing this forum: No registered users and 5 guests