|
|
- - - - - - - - - - - - - - ผู้ให้การสนับสนุน- - - - - - - - - - - - - -
|
|
|
กระทู้ #2031 [Java] (จาก IP: 222.123.210.14)
ช่วยด้วยค่ะด่วนๆๆๆเลยไม่งั้นตายแน่
ให้เขียนโปรแกรมเพื่ตรวจสอบว่าข้อมูลที่รับเข้ามาเป็นPalindome หรือไม่ ใช้ JAVA เขียนอ่ะ
|
จากคุณ
:
prakab / prakab_pang@hotmail.com [2008-05-28 00:29:28]
|
|
ความคิดเห็น #26805 (จาก IP: 203.156.142.66)
อยากช่วยนะ แต่ Palindome คืออะไร ? |
จากคุณ
:
sup98 [2008-05-28 10:41:40]
|
|
ความคิดเห็น #26806 (จาก IP: 202.41.167.246)
พาลินโดรม (palindrome) คือ คำหรือหรือตัวอักษรที่อ่านจากด้านหน้าไปด้านหลัง เหมือนกับอ่านจากด้านหลังไปด้านหน้าและมีความหมายเหมือนกัน เช่น a, non, กนก, ยาย, 1, 11, 121 |
จากคุณ
:
sucomsci [2008-05-28 14:31:54]
|
|
ความคิดเห็น #26807 (จาก IP: 203.156.142.66)
for-loop ตาม ความยาวของคำ(size) แล้วเปรียบเทียบคำตามตำแหน่ง
str[i] เทียบกับ str[size-i]
concept ประมาณนี้เอาไปเขียนเองครับ
|
จากคุณ
:
sup98 [2008-05-28 14:54:57]
|
|
ความคิดเห็น #27115 (จาก IP: 203.158.215.80)
import java.awt.*; import java.awt.event.*; import javax.swing.*;
public class Final_151_2 extends JFrame implements ActionListener, KeyListener{ private final String newline = "\n"; //.ใส่ private final static int foodPrice[] = {10,15,30}; private int countFood=0; private int totalPrice=0; private JLabel lblShow=new JLabel("Select Foods",SwingConstants.CENTER); private String foodName[][]={{"น้ำองุ่น","น้ำสัปปะรด","น้ำส้ม","น้ำแตงโม","น้ำมะพร้าว","น้ำกระเจี๊ยบ","น้ำลำใย"}, {"ลอดช่อง","รวมมิตร","ฝอยทอง","ทับทิมกรอบ","สังขยา","ลูกชุบ","หม้อแกง"}, {"ข้าวมันไก่","ข้าวขาหมู","ข้าวหน้าเป็ด","ก๋วยเตี๋ยวปลา","ต้มยำกุ้ง","ผัดไท","แกงพะโล้"}}; private JComboBox[] foodBox=new JComboBox[3]; //(foodName[0]); private TextArea txtArea=new TextArea("",7,25,0); private JTextField txtTotal=new JTextField(5); private JTextField txtGetMoney=new JTextField(5); private JTextField txtOutMoney=new JTextField(5); private JLabel labelTotal=new JLabel("ราคา"); private JLabel labelGetMoney=new JLabel("รับเงิน"); private JLabel labelOutMoney=new JLabel("ทอนเงิน"); private JPanel panelMoney=new JPanel(); private JPanel panelOne=new JPanel(); private JPanel panelTwo=new JPanel(); private JPanel panelThree=new JPanel(); private JPanel panel123=new JPanel(); private JPanel panelFoods=new JPanel(); private JPanel panelOrder=new JPanel();
public Final_151_2(){ super("Foods Shop"); panelOrder.setLayout(new FlowLayout()); panelFoods.setLayout(new BorderLayout()); lblShow.setFont(new Font(lblShow.getFont().toString(),Font.BOLD,20)); for (int i=0;i<foodName.length ;i++ ){ foodBox[i]=new JComboBox(foodName[i]); panelOrder.add(foodBox[i]); foodBox[i].addActionListener(this); panelFoods.add(panelOrder,BorderLayout.CENTER); } panelFoods.add(lblShow,BorderLayout.NORTH); panelMoney.setLayout(new BorderLayout()); panelOne.setLayout(new FlowLayout(FlowLayout.RIGHT)); panelTwo.setLayout(new FlowLayout(FlowLayout.RIGHT)); panelThree.setLayout(new FlowLayout(FlowLayout.RIGHT)); panel123.setLayout(new GridLayout(3,1)); panelOne.add(labelTotal); panelOne.add(txtTotal); panelTwo.add(labelGetMoney); panelTwo.add(txtGetMoney); panelThree.add(labelOutMoney); panelThree.add(txtOutMoney); panel123.add(panelOne); panel123.add(panelTwo); panel123.add(panelThree); txtArea.setEditable(true); panelMoney.add(txtArea,BorderLayout.NORTH); panelMoney.add(panel123,BorderLayout.CENTER);
Container container = getContentPane(); container.setLayout(new BorderLayout()); container.setBackground(Color.blue); container.add(panelFoods,BorderLayout.WEST); container.add(panelMoney,BorderLayout.EAST); txtGetMoney.addKeyListener(this); setSize(550, 250); setVisible(true); } public static void main(String[] args) { Final_151_2 app = new Final_151_2(); app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
public void actionPerformed(ActionEvent e){ for (int i=0;i<foodBox.length ;i++ ){ if (e.getSource()==foodBox[i]){ txtArea.append(++countFood+"."+foodBox[i].getSelectedItem().toString()+newline); totalPrice+=foodPrice[i]; txtTotal.setText(totalPrice+""); } } } public void keyTyped(KeyEvent e){} public void keyReleased(KeyEvent e){} public void keyPressed(KeyEvent e){ if ((e.getSource()==txtGetMoney)&&(e.getKeyCode()==KeyEvent.VK_ENTER)){ if (Integer.parseInt(txtTotal.getText())<=Integer.parseInt(txtGetMoney.getText())){ txtOutMoney.setText(Integer.parseInt(txtGetMoney.getText())-Integer.parseInt(txtTotal.getText())+""); txtGetMoney.setForeground(Color.BLACK); } if (Integer.parseInt(txtTotal.getText())>Integer.parseInt(txtGetMoney.getText())){ txtOutMoney.setText(""); txtGetMoney.setForeground(Color.RED); } } }
}//class |
จากคุณ
:
qeqeqee / 2332424 [2008-09-22 10:28:18]
|
|
ความคิดเห็น #27116 (จาก IP: 203.158.215.80)
333333333333333333333333333 import java.awt.*; import java.awt.event.*; import javax.swing.*;
public class Final_151_3X extends JFrame implements ActionListener, MouseListener, KeyListener { private final String newline = "\n"; private final static int SHOW = 16; private final static int itemPrice[] = {75,140}; private int countSelect=1; private int selectedItem=1; private int countSelect2=1; private int selectedItem2=1; private String txtSelect ="Dress"; private String txtSelect2 ="Shirt";
private int countItem=0; private int totalPrice=0; private JLabel showPic=new JLabel(new ImageIcon("Dress1.jpg")); private JLabel lblShow=new JLabel("Dress1",SwingConstants.CENTER); private JRadioButton rdoOne = new JRadioButton("BOY"); private JRadioButton rdoTwo = new JRadioButton("GIRL"); private ButtonGroup groupOne = new ButtonGroup(); private JButton btnOne = new JButton("<< Previous"); private JButton btnTwo = new JButton("Next >>");
private TextArea txtArea=new TextArea("",7,25,0); private JTextField txtTotal=new JTextField(5); private JTextField txtGetMoney=new JTextField(5); private JTextField txtOutMoney=new JTextField(5); private JLabel labelTotal=new JLabel("ราคา"); private JLabel labelGetMoney=new JLabel("รับเงิน"); private JLabel labelOutMoney=new JLabel("ทอนเงิน"); private JPanel panelMoney=new JPanel(); private JPanel panelOne=new JPanel(); private JPanel panelTwo=new JPanel(); private JPanel panelThree=new JPanel(); private JPanel panel123=new JPanel();
private JPanel panelItems=new JPanel(); private JPanel panelSelectType=new JPanel(); private JPanel panelBtn=new JPanel(); private JPanel panelShow=new JPanel();
public Final_151_3X(){ super("Shirt and Dress Shop"); groupOne.add(rdoOne); groupOne.add(rdoTwo); panelSelectType.setLayout(new FlowLayout(FlowLayout.CENTER)); panelSelectType.add(rdoOne); panelSelectType.add(rdoTwo); rdoTwo.setSelected(true); panelBtn.setLayout(new FlowLayout(FlowLayout.CENTER)); panelBtn.add(btnOne); panelBtn.add(btnTwo); panelShow.setLayout(new BorderLayout()); panelShow.add(showPic,BorderLayout.CENTER); panelShow.add(lblShow,BorderLayout.SOUTH); panelItems.setLayout(new BorderLayout()); panelItems.add(panelSelectType,BorderLayout.NORTH); panelItems.add(panelShow,BorderLayout.CENTER); panelItems.add(panelBtn,BorderLayout.SOUTH);
panelMoney.setLayout(new BorderLayout()); panelOne.setLayout(new FlowLayout(FlowLayout.RIGHT)); panelTwo.setLayout(new FlowLayout(FlowLayout.RIGHT)); panelThree.setLayout(new FlowLayout(FlowLayout.RIGHT)); panel123.setLayout(new GridLayout(3,1)); panelOne.add(labelTotal); panelOne.add(txtTotal); panelTwo.add(labelGetMoney); panelTwo.add(txtGetMoney); panelThree.add(labelOutMoney); panelThree.add(txtOutMoney); panel123.add(panelOne); panel123.add(panelTwo); panel123.add(panelThree); txtArea.setEditable(false); panelMoney.add(txtArea,BorderLayout.NORTH); panelMoney.add(panel123,BorderLayout.CENTER);
Container container = getContentPane(); container.setLayout(new BorderLayout()); container.setBackground(Color.blue); container.add(panelItems,BorderLayout.WEST); container.add(panelMoney,BorderLayout.EAST);
rdoOne.addActionListener(this); rdoTwo.addActionListener(this); btnTwo.addActionListener(this); btnOne.addActionListener(this); showPic.addMouseListener(this); txtGetMoney.addKeyListener(this); setSize(410, 250); setVisible(true); }
public static void main(String[] args) { Final_151_3X app = new Final_151_3X(); app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
public void actionPerformed(ActionEvent e){ if (e.getSource() == rdoOne){ showPic.setIcon(new ImageIcon(txtSelect2+ selectedItem2+ ".jpg")); lblShow.setText(txtSelect2+ selectedItem2); } if (e.getSource() == rdoTwo){ showPic.setIcon(new ImageIcon(txtSelect+ selectedItem+".jpg")); lblShow.setText(txtSelect+selectedItem); } if (e.getSource()==btnTwo){ if (rdoTwo.isSelected()){ showPic.setIcon(new ImageIcon(txtSelect+ ++selectedItem+".jpg")); lblShow.setText(txtSelect+ ++countSelect); if (countSelect==16){ countSelect=15; selectedItem=15; } } } if (e.getSource()==btnTwo){ if (rdoOne.isSelected()){ showPic.setIcon(new ImageIcon(txtSelect2+ ++selectedItem2+".jpg")); lblShow.setText(txtSelect2+ ++countSelect2); if (countSelect2==16){ countSelect2=15; selectedItem2=15; } } } if (e.getSource()==btnOne){ if (rdoTwo.isSelected()){ showPic.setIcon(new ImageIcon(txtSelect+ --selectedItem+".jpg")); lblShow.setText(txtSelect+ --countSelect); if (countSelect==1){ countSelect=2; selectedItem=2; } } } if (e.getSource()==btnOne){ if (rdoOne.isSelected()){ showPic.setIcon(new ImageIcon(txtSelect2+ --selectedItem2+".jpg")); lblShow.setText(txtSelect2+ --countSelect2); if (countSelect2==1){ countSelect2=2; selectedItem2=2; }
} } }//actionperform public void mouseClicked(MouseEvent e){ if (e.getSource()==showPic){ if (rdoTwo.isSelected()){ txtArea.append(++countItem+"."+txtSelect+selectedItem+newline); totalPrice+=itemPrice[1]; } } if (e.getSource()==showPic){ if (rdoOne.isSelected()){ txtArea.append(++countItem+"."+txtSelect2+selectedItem2+newline); totalPrice+=itemPrice[0]; } } txtTotal.setText(Integer.toString(totalPrice)); }//click public void mouseReleased(MouseEvent e){} public void mousePressed(MouseEvent e){} public void mouseExited(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void keyTyped(KeyEvent e){} public void keyReleased(KeyEvent e){} public void keyPressed(KeyEvent e){ if ((e.getSource()==txtGetMoney)&&(e.getKeyCode()==KeyEvent.VK_ENTER)){ if (Integer.parseInt(txtTotal.getText())<=Integer.parseInt(txtGetMoney.getText())){ txtOutMoney.setText(Integer.parseInt(txtGetMoney.getText())-Integer.parseInt(txtTotal.getText())+""); txtGetMoney.setForeground(Color.BLACK); } if (Integer.parseInt(txtTotal.getText())>Integer.parseInt(txtGetMoney.getText())){ txtOutMoney.setText(""); txtGetMoney.setForeground(Color.RED); } } }
}//class |
จากคุณ
:
3333 / 33333 [2008-09-22 10:52:47]
|
|
ความคิดเห็น #27117 (จาก IP: 203.158.215.80)
3333333333333 แก้ไขใหม่
import java.awt.*; import java.awt.event.*; import javax.swing.*;
public class Final_151_3X extends JFrame implements ActionListener, MouseListener, KeyListener { private final String newline = "\n"; private final static int SHOW = 16; private final static int itemPrice[] = {75,140}; private int countSelect=1; private int selectedItem=1; private int countSelect2=1; private int selectedItem2=1; private String txtSelect ="Dress"; private String txtSelect2 ="Shirt";
private int countItem=0; private int totalPrice=0; private JLabel showPic=new JLabel(new ImageIcon("Dress1.jpg")); private JLabel lblShow=new JLabel("Dress1",SwingConstants.CENTER); private JRadioButton rdoOne = new JRadioButton("BOY"); private JRadioButton rdoTwo = new JRadioButton("GIRL"); private ButtonGroup groupOne = new ButtonGroup(); private JButton btnOne = new JButton("<< Previous"); private JButton btnTwo = new JButton("Next >>");
private TextArea txtArea=new TextArea("",7,25,0); private JTextField txtTotal=new JTextField(5); private JTextField txtGetMoney=new JTextField(5); private JTextField txtOutMoney=new JTextField(5); private JLabel labelTotal=new JLabel("ราคา"); private JLabel labelGetMoney=new JLabel("รับเงิน"); private JLabel labelOutMoney=new JLabel("ทอนเงิน"); private JPanel panelMoney=new JPanel(); private JPanel panelOne=new JPanel(); private JPanel panelTwo=new JPanel(); private JPanel panelThree=new JPanel(); private JPanel panel123=new JPanel();
private JPanel panelItems=new JPanel(); private JPanel panelSelectType=new JPanel(); private JPanel panelBtn=new JPanel(); private JPanel panelShow=new JPanel();
public Final_151_3X(){ super("Shirt and Dress Shop"); groupOne.add(rdoOne); groupOne.add(rdoTwo); panelSelectType.setLayout(new FlowLayout(FlowLayout.CENTER)); panelSelectType.add(rdoOne); panelSelectType.add(rdoTwo); rdoTwo.setSelected(true); panelBtn.setLayout(new FlowLayout(FlowLayout.CENTER)); panelBtn.add(btnOne); panelBtn.add(btnTwo); panelShow.setLayout(new BorderLayout()); panelShow.add(showPic,BorderLayout.CENTER); panelShow.add(lblShow,BorderLayout.SOUTH); panelItems.setLayout(new BorderLayout()); panelItems.add(panelSelectType,BorderLayout.NORTH); panelItems.add(panelShow,BorderLayout.CENTER); panelItems.add(panelBtn,BorderLayout.SOUTH);
rdoOne.addActionListener(this); rdoTwo.addActionListener(this); btnTwo.addActionListener(this); btnOne.addActionListener(this); showPic.addMouseListener(this);
panelMoney.setLayout(new BorderLayout()); panelOne.setLayout(new FlowLayout(FlowLayout.RIGHT)); panelTwo.setLayout(new FlowLayout(FlowLayout.RIGHT)); panelThree.setLayout(new FlowLayout(FlowLayout.RIGHT)); panel123.setLayout(new GridLayout(3,1)); panelOne.add(labelTotal); panelOne.add(txtTotal); panelTwo.add(labelGetMoney); panelTwo.add(txtGetMoney); panelThree.add(labelOutMoney); panelThree.add(txtOutMoney); panel123.add(panelOne); panel123.add(panelTwo); panel123.add(panelThree); txtArea.setEditable(false); panelMoney.add(txtArea,BorderLayout.NORTH); panelMoney.add(panel123,BorderLayout.CENTER);
Container container = getContentPane(); container.setLayout(new BorderLayout()); container.setBackground(Color.blue); container.add(panelItems,BorderLayout.WEST); container.add(panelMoney,BorderLayout.EAST);
txtGetMoney.addKeyListener(this); setSize(410, 250); setVisible(true); }
public static void main(String[] args) { Final_151_3X app = new Final_151_3X(); app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
public void actionPerformed(ActionEvent e){
if (e.getSource() == rdoOne){ showPic.setIcon(new ImageIcon(txtSelect2+ selectedItem2+ ".jpg")); lblShow.setText(txtSelect2+ selectedItem2); } if (e.getSource() == rdoTwo){ showPic.setIcon(new ImageIcon(txtSelect+ selectedItem+".jpg")); lblShow.setText(txtSelect+selectedItem); } if (e.getSource()==btnTwo){ if (rdoTwo.isSelected()){ showPic.setIcon(new ImageIcon(txtSelect+ ++selectedItem+".jpg")); lblShow.setText(txtSelect+ ++countSelect); if (countSelect==16){ countSelect=15; selectedItem=15; }
} } if (e.getSource()==btnTwo){ if (rdoOne.isSelected()){ showPic.setIcon(new ImageIcon(txtSelect2+ ++selectedItem2+".jpg")); lblShow.setText(txtSelect2+ ++countSelect2); if (countSelect2==16){ countSelect2=15; selectedItem2=15; }
} } if (e.getSource()==btnOne){ if (rdoTwo.isSelected()){ showPic.setIcon(new ImageIcon(txtSelect+ --selectedItem+".jpg")); lblShow.setText(txtSelect+ --countSelect); if (countSelect==1){ countSelect=2; selectedItem=2; } } } if (e.getSource()==btnOne){ if (rdoOne.isSelected()){ showPic.setIcon(new ImageIcon(txtSelect2+ --selectedItem2+".jpg")); lblShow.setText(txtSelect2+ --countSelect2); if (countSelect2==1){ countSelect2=2; selectedItem2=2; }
} } }//actionperform public void mouseClicked(MouseEvent e){ if (e.getSource()==showPic){ if (rdoTwo.isSelected()){ txtArea.append(++countItem+"."+txtSelect+selectedItem+newline); totalPrice+=itemPrice[1]; } } if (e.getSource()==showPic){ if (rdoOne.isSelected()){ txtArea.append(++countItem+"."+txtSelect2+selectedItem2+newline); totalPrice+=itemPrice[0]; } } txtTotal.setText(Integer.toString(totalPrice)); }//click public void mouseReleased(MouseEvent e){} public void mousePressed(MouseEvent e){} public void mouseExited(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void keyTyped(KeyEvent e){} public void keyReleased(KeyEvent e){} public void keyPressed(KeyEvent e){ if ((e.getSource()==txtGetMoney)&&(e.getKeyCode()==KeyEvent.VK_ENTER)){ if (Integer.parseInt(txtTotal.getText())<=Integer.parseInt(txtGetMoney.getText())){ txtOutMoney.setText(Integer.parseInt(txtGetMoney.getText())-Integer.parseInt(txtTotal.getText())+""); txtGetMoney.setForeground(Color.BLACK); } if (Integer.parseInt(txtTotal.getText())>Integer.parseInt(txtGetMoney.getText())){ txtOutMoney.setText(""); txtGetMoney.setForeground(Color.RED); } }
}
}//class |
จากคุณ
:
-----------แก้ใหม่ขขขขขขขขขขขขข / -----------------33333333333------------ [2008-09-22 11:16:22]
|
|
|
- - - - - - - - - - - - - - ผู้ให้การสนับสนุน- - - - - - - - - - - - - -
|
|
|
|
|