디시인사이드 갤러리

갤러리 이슈박스, 최근방문 갤러리

갤러리 본문 영역

횽들 도와줘영 ㅜㅜ

횽들 도와줭 (124.51) 2011.12.16 16:01:22
조회 52 추천 0 댓글 2

 횽들 array의 총합을 구하려고하는데 500 + -300을 한다고 치면 답이 700으로 나오고 list 버튼을 클릭하면 결과가 한번 나오게 하고싶은데 누를때마다 숫자가 계속 바껴 ㅠ 집에서 쓸 간단한 가계부 프로그램 만드려는데.. 자바코드에여


import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.Font;
import javax.swing.JTextArea;
import java.text.NumberFormat;

class Mainmenu extends JFrame implements ActionListener
{
    int max = 10;
    double alltotal = 0;
    String[ ] name = new String[max];
    double[ ] amount = new double[max];
    double totala = 0;
    int a = 0;    
    int b = 0;

    private static final int FRAME_WIDTH = 500;
    private static final int FRAME_HEIGHT = 500;
    private static final int FRAME_X_ORIGIN = 440;
    private static final int FRAME_Y_ORIGIN = 440;

    private static final int BUTTON_WIDTH = 80;
    private static final int BUTTON_HEIGHT = 30;

    private JButton addButton;
    private JButton deleteButton;
    private JButton listButton;
    private JButton wishlistButton;
    private JButton quitButton;
    private JButton howtouseButton;

    public static void main(String[] args) 
    {
        Mainmenu frame = new Mainmenu();
        frame.setVisible(true);
    }

    public Mainmenu ( )
    {
        setTitle ("Moneybook");
        setSize (FRAME_WIDTH, FRAME_HEIGHT);
        setLocation (FRAME_X_ORIGIN, FRAME_Y_ORIGIN);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        Container contentPane = getContentPane();
        contentPane.setLayout(null);
        contentPane.setBackground(Color.white);

        JTextArea text = new JTextArea();
        setLayout(null);
        add(text);
        text.setBounds(100, 3, 300, 100);
        Font font = new Font("Serif", Font.BOLD, 52);
        text.setFont(font);
        text.setText ("MoneyBook");

        addButton = new JButton("Add");
        addButton.setBounds(200, 120, BUTTON_WIDTH, BUTTON_HEIGHT);
        addButton.addActionListener(this);
        contentPane.add(addButton);

        deleteButton = new JButton("Delete");
        deleteButton.setBounds(200, 180, BUTTON_WIDTH, BUTTON_HEIGHT);
        deleteButton.addActionListener(this);
        contentPane.add(deleteButton);

        listButton = new JButton("List");
        listButton.setBounds(200, 240, BUTTON_WIDTH, BUTTON_HEIGHT);
        listButton.addActionListener(this);
        contentPane.add(listButton);

        wishlistButton = new JButton("Wishlist");
        wishlistButton.setBounds(200, 300, BUTTON_WIDTH, BUTTON_HEIGHT);
        wishlistButton.addActionListener(this);
        contentPane.add(wishlistButton);

        quitButton = new JButton("Quit");
        quitButton.setBounds(200, 360, BUTTON_WIDTH, BUTTON_HEIGHT);
        quitButton.addActionListener(this);
        contentPane.add(quitButton);

        howtouseButton = new JButton("How to use");
        howtouseButton.setBounds(324, 432, 160, BUTTON_HEIGHT);
        howtouseButton.addActionListener(this);
        contentPane.add(howtouseButton);
    }

    public void actionPerformed(ActionEvent event)
    {      
        for ( int i = 0; i < max; i++ )
        {
            totala += amount[i];
        }
        JButton clickedButton = (JButton) event.getSource();
        System.out.print('\f');
        if (clickedButton == addButton)
        {
            name[a] = JOptionPane.showInputDialog("Make a name for your income or outcome");
            amount[a] = Double.parseDouble(JOptionPane.showInputDialog("Enter the amount you earn or lost [State the outcome by typing - infront of number]"));
            a = a + 1;
        }

        if (clickedButton == deleteButton)
        {
            String searchName = JOptionPane.showInputDialog("Enter the name that you made for your income or outcome");
            for (int i=0; i<max; i++)
            {
                if (searchName.equals(name[i]))
                {
                    name[i] = null;
                    amount[i] = 0;
                }
            }
        }

        if (clickedButton == listButton)
        {
            for (int i=0; i<max; i++) 
            {
                if (name[i] != null)
                {
                    System.out.println("Title:"+name[i]);
                    System.out.println("Amount: $"+amount[i]);
                }
                System.out.println("Total amount:"+ totala);
            }
        }

        if (clickedButton == wishlistButton)
        {
        }

        if (clickedButton == quitButton)
        {
            JOptionPane.showMessageDialog(null, "Thank you for using Moneybook");
            System.exit(0);
        }

        if (clickedButton == howtouseButton)
        {
            JOptionPane.showMessageDialog(null, "[Moneybook]\nClick the \n*Add button to add your income or outcome status\n*Delete button to delete your income or outcome status\n*List button to list your balance\n*Wishlist button to add,delete and list your wish product.\n*Quit button to exit the program");
        }
    }
}
>

추천 비추천

0

고정닉 0

0

댓글 영역

전체 댓글 0
본문 보기

하단 갤러리 리스트 영역

왼쪽 컨텐츠 영역

갤러리 리스트 영역

갤러리 리스트
번호 제목 글쓴이 작성일 조회 추천
설문 해외에서 겪는 불합리한 대우에 대응 잘 할 것 같은 스타는? 운영자 25/11/03 - -
AD 저녁 뭐먹지? 오늘의 메뉴 추천! 운영자 25/10/31 - -
294747 뇌지랄 책산사람있음? [5] 타살춤(59.3) 11.12.16 182 0
294745 자바인데 도와주실분 사례드림 라이커리갤로그로 이동합니다. 11.12.16 60 0
294743 메모장 열고 F5버튼 누르면 날짜 나오듯이 [3] 리눅슽(121.186) 11.12.16 109 0
294742 줫밥횽은 봅니다. 캐줫밥닭(115.92) 11.12.16 51 0
294741 비쥬얼 스튜디오 2010 사용하는 사람들 .. ssonacy갤로그로 이동합니다. 11.12.16 115 0
294740 나도 한번 해볼까 - 엑스칼리버 = ω=)ษิีึืิีึืิีึืิีึืิีึืิีึืิีึืิีึื [1] 땡칠도사갤로그로 이동합니다. 11.12.16 110 0
294739 네이티브어플맹글때 질문. [3] 고추장불고기갤로그로 이동합니다. 11.12.16 79 0
294738 Mathematica.... 땡칠도사갤로그로 이동합니다. 11.12.16 91 0
294737 크리스마스 이브가 일주일 남았다 - 광선검(ส°ㅅ°)ส 거칠게갤로그로 이동합니다. 11.12.16 67 0
294736 아~ 안녕 플갤이여~ ㅜ,.ㅜ [3] 개심심(61.73) 11.12.16 80 0
294735 횽들 ppt 복구 방법 없나여? ㅠㅠ [4] 일광면(119.198) 11.12.16 212 0
294734 리눅스에서 쉘로 간단한 자바 파일 컴파일하고 실행하는방법좀요... 늅늅(175.198) 11.12.16 42 0
294733 이쁜여자 많다는 인픽스라는 회사는 머배워야 들어갈수 이씀??? [5] 복실이(121.174) 11.12.16 200 0
294732 씹돼지.. [3] 줫밥(122.49) 11.12.16 130 0
294731 퇴근 15분 전입니다 고갱님~광선검(ส°ㅅ°)ส [1] 거칠게갤로그로 이동합니다. 11.12.16 82 0
294729 오에~~ 망해따 [1] 일광면(119.198) 11.12.16 59 0
294728 싸지른글 모두 폭파완료 하암 주말들 잘보내귀 줫밥(122.49) 11.12.16 47 0
294727 부산에 IT회사 취직자리 많나요?? [4] 까꼬이(121.174) 11.12.16 264 0
294726 연말이라고 커플들 하나 둘 생겨나는거냐 ㅠㅠㅠ 우씨 ㅠㅠ [3] coding갤로그로 이동합니다. 11.12.16 93 0
294723 줫밥 형 php 어느 정도 수준이어야 입사 가능해요? [15] bbbb(210.90) 11.12.16 180 0
294720 줫밥 & 아스... 니내 꼮 사귀어라. [8] 프게이(116.125) 11.12.16 118 0
294717 인증 ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ [13] 줫밥(122.49) 11.12.16 264 0
294715 으 화수목 야근해서 2시퇴근하게해줌 개떙보갤로그로 이동합니다. 11.12.16 54 0
294714 비주얼스튜디오 클래스뷰에 화살표 표시 무슨뜻? [4] ㅋㄱ(183.96) 11.12.16 109 0
294713 나 지금 줫밥형 만나러 간다 [6] McHello갤로그로 이동합니다. 11.12.16 145 0
294711 형들 살려줘 복룡갤로그로 이동합니다. 11.12.16 42 0
294709 겨울방학 프로그래밍 C.C++.자바 특강 안내 [1] 솔맨갤로그로 이동합니다. 11.12.16 119 0
횽들 도와줘영 ㅜㅜ [2] 횽들 도와줭 (124.51) 11.12.16 52 0
294701 IE진짜 개구린거 같음 [2] Mihark(219.239) 11.12.16 76 0
294700 to. 김국진 [2] 줫밥(122.49) 11.12.16 70 0
294698 야 대한민국 국민소득 25000불이면 한가정당 10만불 이잖아 [1] 12(125.7) 11.12.16 91 0
294696 횽들 .net으로 웹개발중인데, 플래시랑 통신하는거땜에 [1] Mihark(219.239) 11.12.16 61 0
294695 하암 빨리 다른걸 해야할탠데 줫밥(122.49) 11.12.16 47 0
294693 HTML 소스좀 수정 부탁드릴려구요... 고수님들하 부탁좀 [9] 안사장님(124.111) 11.12.16 96 0
294691 남자나이 28세 그것은 가장 멋있을 때 [3] Lover♥갤로그로 이동합니다. 11.12.16 144 0
294688 이번 학기 성적이 기대댄다 Lover♥갤로그로 이동합니다. 11.12.16 72 0
294687 약삿당 핰핰 [4] 줫밥(122.49) 11.12.16 90 0
294684 리눅스에서 vi로 자바 소스 작성중인데.... [1] 늅늅(175.198) 11.12.16 89 0
294682 root file system에서 nand에 r/w하는 방법 아는사람~ [1] 깁순대갤로그로 이동합니다. 11.12.16 52 0
294681 월 소득 500이 하층민 [1] 9m(203.236) 11.12.16 116 0
294677 다 끝났다..... [1] 땡칠도사갤로그로 이동합니다. 11.12.16 67 0
294675 cString [2] iljeomobolt갤로그로 이동합니다. 11.12.16 62 0
294674 세후 1400 vs 세전 1400 12(125.7) 11.12.16 66 0
294672 어제 회사면접을 봤는데.. [3] ㄱㄱㄱㄱ(211.48) 11.12.16 133 0
294671 횽들 크리스마스 선물이얍 [1] 쿄스케갤로그로 이동합니다. 11.12.16 59 0
294669 자바 배열이랑 클래스 질문좀!!독학인에게 힘을 주thㅔ요 [6] 자바궁금증(211.117) 11.12.16 79 0
294668 음 리얼포스 사러갈껀데 뭐사지? [10] 개떙보갤로그로 이동합니다. 11.12.16 130 0
294664 근데 프로그래머가 나중에 취업할 때 학벌이 꽤 중요하게 작용하나요? [3] 123(121.170) 11.12.16 186 0
294663 '윗층 소음 보복법' 폭소, 우퍼 천장에 설치해 응징 [3] 쿄스케갤로그로 이동합니다. 11.12.16 598 0
294659 to.포항의봄 [2] 줫밥(122.49) 11.12.16 89 0
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

디시미디어

디시이슈

1/2