디시인사이드 갤러리

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

갤러리 본문 영역

횽들 도와줘영 ㅜㅜ

횽들 도와줭 (124.51) 2011.12.16 16:01:22
조회 57 추천 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/24 - -
이슈 [디시人터뷰] 충무로가 주목하는 신예, '세계의 주인' 서수빈 운영자 25/11/24 - -
AD 대학생 필수템! What's in my Bag 운영자 25/11/21 - -
294789 추워서 코딩을 못하겠다... 쿄스케갤로그로 이동합니다. 11.12.17 45 0
294788 일어나라 프갤러들이여 [2] 플래닛댄스갤로그로 이동합니다. 11.12.17 84 0
294787 와 시발 독종세끼 [1] Adelposs갤로그로 이동합니다. 11.12.17 96 0
294786 어플 만들어서 돈 버는 사람 있냐? [1] ㅇㅇ(211.195) 11.12.17 145 0
294783 프갤러 수준은 어느정도임? [9] 리눅슽(121.186) 11.12.17 195 0
294782 웹서버 코딩하면 실력있는거임? [9] 마타버터갤로그로 이동합니다. 11.12.17 235 0
294781 대기업 유지보수 어때요?? [2] 이메지네이션(211.187) 11.12.17 142 0
294780 교양이 문제야 교양이.... elwlwlwk갤로그로 이동합니다. 11.12.17 69 0
294779 구조체, 문자 포인터 질문 [4] 질문(210.119) 11.12.17 126 0
294776 자바스크립트 공부했던 뉴비의 푸념. [1] Js뉴비(116.124) 11.12.17 133 0
294775 개발자 블랙리스트 가 사실이야??? [3] 거칠게갤로그로 이동합니다. 11.12.17 326 0
294774 내트워킹 관련 개발한다고 하면 [4] 전원버튼갤로그로 이동합니다. 11.12.17 109 0
294771 c++ 리소스 사용하는법점여 [6] DevilCruiser갤로그로 이동합니다. 11.12.17 94 0
294767 shutdown -a [1] pc-keeper(115.139) 11.12.16 102 0
294762 오늘의 이야기 ~ ㅋ [4] 좋은아버지갤로그로 이동합니다. 11.12.16 84 0
294761 오늘은 좋은아버지횽 안오나 [1] 三didas갤로그로 이동합니다. 11.12.16 61 0
294760 보통 현업에서 JSP 어떻게 써? JSTL 씀?? [23] ㅌㄹ(59.26) 11.12.16 145 0
294756 3N 중에서 어디가 예쁜 여자 많음? [2] ㅇㅇ(121.133) 11.12.16 170 0
294755 횽들 asp.net mvc 책좀 추천해줘. Mihark(219.239) 11.12.16 63 0
294754 애슐리 가지 마라 사람 좆도 많다. [1] 거칠게갤로그로 이동합니다. 11.12.16 109 0
294753 존나 춥다며? [2] monoless갤로그로 이동합니다. 11.12.16 74 0
294752 흔한 컴덕유머.jpg [4] warota(221.150) 11.12.16 250 0
294751 날씨 왜케 덥냐 [3] 알탱o갤로그로 이동합니다. 11.12.16 83 0
294749 진짜 씨부랄 개같애서 못해먹겠다 [3] 므해?갤로그로 이동합니다. 11.12.16 145 0
294748 저 vector의 간략한 질문 좀요ㅠ.... [1] 구원손길좀(1.211) 11.12.16 72 0
294747 뇌지랄 책산사람있음? [5] 타살춤(59.3) 11.12.16 189 0
294745 자바인데 도와주실분 사례드림 라이커리갤로그로 이동합니다. 11.12.16 66 0
294743 메모장 열고 F5버튼 누르면 날짜 나오듯이 [3] 리눅슽(121.186) 11.12.16 116 0
294742 줫밥횽은 봅니다. 캐줫밥닭(115.92) 11.12.16 57 0
294741 비쥬얼 스튜디오 2010 사용하는 사람들 .. ssonacy갤로그로 이동합니다. 11.12.16 117 0
294740 나도 한번 해볼까 - 엑스칼리버 = ω=)ษิีึืิีึืิีึืิีึืิีึืิีึืิีึืิีึื [1] 땡칠도사갤로그로 이동합니다. 11.12.16 113 0
294739 네이티브어플맹글때 질문. [3] 고추장불고기갤로그로 이동합니다. 11.12.16 86 0
294738 Mathematica.... 땡칠도사갤로그로 이동합니다. 11.12.16 95 0
294737 크리스마스 이브가 일주일 남았다 - 광선검(ส°ㅅ°)ส 거칠게갤로그로 이동합니다. 11.12.16 72 0
294736 아~ 안녕 플갤이여~ ㅜ,.ㅜ [3] 개심심(61.73) 11.12.16 84 0
294735 횽들 ppt 복구 방법 없나여? ㅠㅠ [4] 일광면(119.198) 11.12.16 217 0
294734 리눅스에서 쉘로 간단한 자바 파일 컴파일하고 실행하는방법좀요... 늅늅(175.198) 11.12.16 50 0
294733 이쁜여자 많다는 인픽스라는 회사는 머배워야 들어갈수 이씀??? [5] 복실이(121.174) 11.12.16 205 0
294732 씹돼지.. [3] 줫밥(122.49) 11.12.16 135 0
294731 퇴근 15분 전입니다 고갱님~광선검(ส°ㅅ°)ส [1] 거칠게갤로그로 이동합니다. 11.12.16 87 0
294729 오에~~ 망해따 [1] 일광면(119.198) 11.12.16 66 0
294728 싸지른글 모두 폭파완료 하암 주말들 잘보내귀 줫밥(122.49) 11.12.16 53 0
294727 부산에 IT회사 취직자리 많나요?? [4] 까꼬이(121.174) 11.12.16 268 0
294726 연말이라고 커플들 하나 둘 생겨나는거냐 ㅠㅠㅠ 우씨 ㅠㅠ [3] coding갤로그로 이동합니다. 11.12.16 98 0
294723 줫밥 형 php 어느 정도 수준이어야 입사 가능해요? [15] bbbb(210.90) 11.12.16 185 0
294720 줫밥 & 아스... 니내 꼮 사귀어라. [8] 프게이(116.125) 11.12.16 122 0
294717 인증 ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ [13] 줫밥(122.49) 11.12.16 269 0
294715 으 화수목 야근해서 2시퇴근하게해줌 개떙보갤로그로 이동합니다. 11.12.16 58 0
294714 비주얼스튜디오 클래스뷰에 화살표 표시 무슨뜻? [4] ㅋㄱ(183.96) 11.12.16 113 0
294713 나 지금 줫밥형 만나러 간다 [6] McHello갤로그로 이동합니다. 11.12.16 151 0
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

디시미디어

디시이슈

1/2