디시인사이드 갤러리

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

갤러리 본문 영역

횽들 도와줘영 ㅜㅜ

횽들 도와줭 (124.51) 2011.12.16 16:01:22
조회 55 추천 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/10 - -
AD 겨울가전 SALE! 쿨한 겨울 HOT세일 운영자 25/11/12 - -
295701 性탄절 [5] iljeomobolt갤로그로 이동합니다. 11.12.23 165 0
295696 100키로이상만 보셈 [2] 줫밥(122.49) 11.12.23 108 0
295694 자바스크립트 쓰다가 갑자기 급궁금증? [1] 개심심(61.73) 11.12.23 127 0
295692 근데 너네 군대는 갔다왔냐? [2] ㅊㄹ(222.112) 11.12.23 88 0
295690 내가 현실보단 이상주의자라서 그런걸까.... [1] 야요이갤로그로 이동합니다. 11.12.23 68 0
295689 서블릿이 웹서버 같은건가요??? 뭐하는 것인지 모르겠어요 ㅠㅠ [1] 외국인(182.211) 11.12.23 95 0
295688 오픈지엘 ES 2.0 좀 아는 횽 있나여? [2] opengl(115.95) 11.12.23 109 0
295686 충++ [1] 천회장(14.52) 11.12.23 82 0
295684 곽 여기 왜오는거임 줫밥(122.49) 11.12.23 61 0
295681 오오미 팀장님 왕따시키는거 보니 프갤벌레들 수준이 뉴스 나올감이네 [2] 곽노현차장(59.13) 11.12.23 133 1
295679 to. ㅡㅡ [1] 줫밥(122.49) 11.12.23 56 0
295678 즷밥님아 ㅡㅡ [1] ㅡㅡ(175.198) 11.12.23 73 0
295677 설마 오늘도 야근하는 횽들은 없겠지??? 거칠게갤로그로 이동합니다. 11.12.23 70 0
295675 이번 대구 중학생 사건 가해자 신상 슬슬 나오던데 [1] 123(125.7) 11.12.23 481 5
295674 SI,솔루션 그 외엔 뭐 임 ?? [6] 야요이갤로그로 이동합니다. 11.12.23 135 0
295673 곽노현팀장 [3] 퓨리님(111.91) 11.12.23 96 0
295672 퇴근 까지 3시간! 직딩들아 지금 뭐하는지 써보랑께 잠깐 휴식하자 [4] ㅊㄹ(222.112) 11.12.23 78 0
295671 횽들 나 파이썬 책 하나만 추천해죠(개왕왕왕왕초보) 꽥꽥꾸르릉꿍갤로그로 이동합니다. 11.12.23 304 0
295670 대표님 제발 저희회사도 상장좀 ㅜㅠㅜ [6] 줫밥(122.49) 11.12.23 116 0
295669 학교는 사회의 축소판이다. [1] ㅇㅇ(182.209) 11.12.23 87 0
295667 횽들 경력 기술서는 어떻게 쓰는꺼얌? 돌리안(121.131) 11.12.23 58 0
295666 쿄스케 인기쩌네 [6] 줫밥(122.49) 11.12.23 112 0
295665 그럼 다들 이 여자아이에 대해서 어떻게 생각함.jpg [7] ㅁㄴㅇㄹ(115.137) 11.12.23 176 0
295664 야 프로그래밍 취미로 할만하냐 [5] 가격거품갤로그로 이동합니다. 11.12.23 162 0
295663 다른 건 몰라도 [3] -ㅂ-(210.90) 11.12.23 65 0
295659 나 예전부터 궁금한게 집단 따돌림 하는 애들의 심리..... [4] 야요이갤로그로 이동합니다. 11.12.23 152 0
295658 프갤하는형들 10명도안되는거같다.. [3] ㅊㄹ(222.112) 11.12.23 96 1
295656 프갤 가가방 들어갔는데 Lover♥갤로그로 이동합니다. 11.12.23 65 0
295654 플래쉬 파일 질문 좀 하겠습니다. [2] ares4you갤로그로 이동합니다. 11.12.23 61 0
295653 너네 보험 펀드 적금 예금 연금 이런거 신경 쓰고 삼? [1] 123(125.7) 11.12.23 55 0
295652 쿄스케형.. [5] ㅡㅡ(175.198) 11.12.23 77 0
295651 프로그래머 = 덕후 이거 절대적인 공식 아님 ?? [5] 야요이갤로그로 이동합니다. 11.12.23 150 0
295650 형님들 조언 고마워. [1] 형님들(116.33) 11.12.23 71 0
295649 ㅅㄱㅅㄱㅅㄱ형 존나 고마워 ㅡㅡ [18] ㅡㅡ(175.198) 11.12.23 122 0
295647 꼭 봐라 프게이들아 대구 여학생 자살 사건 [10] 123(125.7) 11.12.23 255 0
295646 40분만에 흡입했네 [2] 줫밥(122.49) 11.12.23 81 0
295640 형들 질문이 있는데 SI업체랑 솔루션업체랑 특징이랑 차이점이 뭐야? [8] ㅊㄹ(222.112) 11.12.23 198 0
295638 들여쓰기 잘못된 걸 보면 못 참겠다. [3] 토페갤로그로 이동합니다. 11.12.23 110 0
295637 입개르 여기 엑스코드 쓰는 샛기들은 없냐? [4] 문하상품권갤로그로 이동합니다. 11.12.23 78 0
295636 자료구조 갑자기 기억이 안나는데... [4] 에이시아(203.90) 11.12.23 85 0
295635 크리스마스 이후에 네이버 지식검색 탑3 키워드 [6] 쿄스케갤로그로 이동합니다. 11.12.23 119 0
295634 올반교실서크아중 [1] 복룡갤로그로 이동합니다. 11.12.23 75 0
295633 45000원짜리 점심 먹으러옴 ㅇㅇ [3] 헝그리박갤로그로 이동합니다. 11.12.23 119 0
295632 진짜 궁금한데 현 IT종사자들아.. 너희 회사엔 여자 있냐? [13] 므해?갤로그로 이동합니다. 11.12.23 245 0
295631 횽들 웹페이지 서버 올릴때 뭐써????? [3] ㅁㄴㅇㄹ(115.137) 11.12.23 89 0
295630 백운 호수 근처 까페 가본 사람 잇음? [6] 외계달팽갤로그로 이동합니다. 11.12.23 363 0
295629 안드로이드 어플 개발하고 싶은데 [4] 힘드네(59.28) 11.12.23 137 0
295628 분노의 파워코딩 5일차, [3] [성대아싸]갤로그로 이동합니다. 11.12.23 137 0
295625 오 지쟈스 1주일만에 업무가 떨어졌다 개심심(61.73) 11.12.23 65 0
295624 채팅방 오픈 들어와라 줫밥(122.49) 11.12.23 81 0
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

디시미디어

디시이슈

1/2