디시인사이드 갤러리

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

갤러리 본문 영역

횽들 도와줘영 ㅜㅜ

횽들 도와줭 (124.51) 2011.12.16 16:01:22
조회 56 추천 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/17 - -
AD 겨울가전 SALE! 쿨한 겨울 HOT세일 운영자 25/11/12 - -
296181 c언어 빈도수 관련 문제입니다.. 도와주세요! [7] 도와주세요.(175.127) 11.12.27 182 0
296180 오랜만이요 ㅋㅋ [12] 딘윈체스터.갤로그로 이동합니다. 11.12.27 205 0
296179 winapi 이 사이트 존내 좋은듯ㅎㅎ [1] 1(118.220) 11.12.27 122 0
296177 php질문점 [3] ㅇㅇ(211.253) 11.12.27 97 0
296176 오늘 회식하는데 [3] ㅇㅇㅇ(59.150) 11.12.27 94 0
296175 구조체포인터 값 초기화하는방법아는사람 없음? [8] 횽들(222.109) 11.12.27 169 0
296173 졸린 프겔러들을 위한 걸그룹 뮤직비디오 투척 [3] 거칠게갤로그로 이동합니다. 11.12.27 100 0
296172 뒤에서 자꾸 껄떡대는 차장때문에.. 웹툰을 못 보겠따 [4] 므해?갤로그로 이동합니다. 11.12.27 135 0
296171 힘이 빠진다 [8] !@#ㅇㅇ갤로그로 이동합니다. 11.12.27 103 0
296170 앗 쿄스케형~ Lover♥갤로그로 이동합니다. 11.12.27 60 0
296168 형들. 3차원 배열이 그렇게 쓸때가 없나여??? [4] ㅁㅁㅁ(116.121) 11.12.27 166 0
296167 혹시 HTML5 초고수형들 있어??? [2] 늅뉴비(203.253) 11.12.27 236 0
296166 이 넓은 사무실에 나홀로.. [2] Lover♥갤로그로 이동합니다. 11.12.27 106 0
296162 님들 근데 완성된 프로그램 컴파일 하면 왜 안됨? [1] 1(118.220) 11.12.27 85 0
296161 행님들 다이렉트3D에서 말이죠.. ㅇㅇ(58.141) 11.12.27 61 0
296160 웹프로그래머로 취칙하고 싶은데 포트폴리오 [2] 안숭(211.197) 11.12.27 231 0
296158 질문 [6] 횽들(222.109) 11.12.27 90 0
296157 학원 그냥 암때나 다녀도되려나? 정부 200만원 지원 받는걸루해서.. [8] 줫밥(122.49) 11.12.27 347 0
296156 혹시 d3d에 다른 화면이나 윈도우 렌더링 하는법 아는사람? [1] 사과갤로그로 이동합니다. 11.12.27 63 0
296155 이책 읽어 본 형 있어?.? [5] 볼일같은잠(118.41) 11.12.27 145 0
296154 c/c++ 기본 제공되는 함수 알려면 어떻게 해야함? [7] 1(183.104) 11.12.27 108 0
296152 형들 허접 c질문이야요. [4] 추광(203.253) 11.12.27 77 0
296151 자바스크립트 책추천좀 [2] 늅늅이(211.253) 11.12.27 102 0
296150 안드로이드 in-app 써본 형들 ㅠ [3] belkin갤로그로 이동합니다. 11.12.27 76 0
296148 대학 학기끝나니까 똥글들 안올리오네 HarlemLuiah갤로그로 이동합니다. 11.12.27 86 0
296147 폰으로 바로올리기 테스트 ver 0.1 [6] HarlemLuiah갤로그로 이동합니다. 11.12.27 129 0
296146 냠냠 [1] 정수정•‿•갤로그로 이동합니다. 11.12.27 69 0
296144 형들은 말야 (+캐꼬형 소환글) [10] Dawnwalkre갤로그로 이동합니다. 11.12.27 274 0
296142 루프가 계속 돌게 하고 싶은데 무슨 방법이 없을까? [3] 계란밥(210.117) 11.12.27 100 0
296141 오후 시작하기 전에 노래하나 듣고 시작하자~ slow motion [2] 쿄스케갤로그로 이동합니다. 11.12.27 56 0
296139 니들 패션왕이라는 웹툰은 보고 갤질이냐?? [11] 쿄스케갤로그로 이동합니다. 11.12.27 393 0
296136 현업자들에게 질문 밥 먹을때 혼자먹음? 부서끼리 먹음? [2] 므해?갤로그로 이동합니다. 11.12.27 140 0
296133 써니의 매력은 이거 아니겠어?? [1] 거칠게갤로그로 이동합니다. 11.12.27 93 0
296132 비베로 짜인 .exe 프로그램 수정할수있는 능력자 돈벌고싶으면 들어와보아 [3] 류담(119.194) 11.12.27 146 0
296131 키보드 같은거 이제 필요 없음 [2] 시불라미갤로그로 이동합니다. 11.12.27 93 0
296130 써니나 보고 점심 딸이나 쳐라!! [1] 거칠게갤로그로 이동합니다. 11.12.27 160 0
296128 통유리키보드 어쨋다 하는데 [2] HarlemLuiah갤로그로 이동합니다. 11.12.27 84 0
296127 내친구 24살인데 아직 동정.. 30살까지 못할거같다 [3] 므해?갤로그로 이동합니다. 11.12.27 174 0
296124 이상적인 맛폰 키보드 [1] -ㅂ-(210.90) 11.12.27 91 0
296123 나도 라섹했었어 [9] 좋은아버지갤로그로 이동합니다. 11.12.27 289 0
296122 오픈소스 통유리 키보드 [2] pumoo갤로그로 이동합니다. 11.12.27 147 0
296121 아 스벌 개섹기 y녀6디리(211.246) 11.12.27 58 0
296120 스마트폰 한글 입력 방식 어캐 생각하냐 [1] 천회장(14.52) 11.12.27 118 0
296118 형들 안녕? [6] 좋은아버지갤로그로 이동합니다. 11.12.27 84 0
296116 QT로 안드로이드앱 맹글기 [2] 시불라미갤로그로 이동합니다. 11.12.27 195 0
296114 올 진짜 이펙티브 c++ 나왔다. 개떙보갤로그로 이동합니다. 11.12.27 181 0
296112 삼성시가총액이 오라클 넘었대 [2] ㅌㅅㅇ(61.42) 11.12.27 114 0
296111 아 장염걸렷다 ㅠㅠ [1] 싴보이갤로그로 이동합니다. 11.12.27 53 0
296110 초간단 3d 엔진 ,자바스크립트, HTML5, 크롬, 파폭만 [5] [성대아싸]갤로그로 이동합니다. 11.12.27 159 0
296108 년말이다. 은꼴이나 보고 내년을 맞이하자. [6] iljeomobolt갤로그로 이동합니다. 11.12.27 258 0
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

디시미디어

디시이슈

1/2