디시인사이드 갤러리

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

갤러리 본문 영역

횽들 도와줘영 ㅜㅜ

횽들 도와줭 (124.51) 2011.12.16 16:01:22
조회 48 추천 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
본문 보기

하단 갤러리 리스트 영역

왼쪽 컨텐츠 영역

갤러리 리스트 영역

갤러리 리스트
번호 제목 글쓴이 작성일 조회 추천
설문 영포티룩도 멋지게 소화할 것 같은 40대 스타는? 운영자 25/10/27 - -
AD 저녁 뭐먹지? 오늘의 메뉴 추천! 운영자 25/10/31 - -
294939 나의 퇴사 썰. [1] 이런개새끼갤로그로 이동합니다. 11.12.18 116 0
294938 모 일케 갈켜주는 사람이 읍냐ㅇㅇ C 공부좀 할래면 어떠카냐고 묻는데 [4] 미케닠갤로그로 이동합니다. 11.12.18 94 0
294937 어떤 os가 가장 전망성 높을까 [1] 전망(115.41) 11.12.18 93 0
294936 html 질문좀.. 1111(124.195) 11.12.18 35 0
294935 형들 이거쉬운건데 제발알려주세요 ㅠㅠㅠㅠㅠ [1] ㄴㅇㄹㄴㅇ(125.129) 11.12.18 52 0
294934 내가 봤을 때 물어보는 놈들은 존나게 맞아야 한다. [1] ㅇㅇ(61.43) 11.12.18 96 0
294933 프로그램좀 짜주세요. 급함 ㅠ 사례함 [7] 라면사리(110.14) 11.12.18 146 0
294932 일본 스마트폰 개발자 '몸값=금값' [5] ㅁㄴㅇㄹ(14.42) 11.12.18 219 0
294931 프통령하고 스터디 하구 왔심 [3] 9m(58.140) 11.12.18 81 0
294929 InputStream 과 BufferedReader [6] 케이갤로그로 이동합니다. 11.12.18 74 0
294928 면접볼때 주량이랑 여친있냐고 물어보던데 [8] 123(211.48) 11.12.18 230 0
294927 횽들 전자공학 1학년인데 C언어 공부좀 해보려고하는데 어케해야됨? 학원다 미케닠갤로그로 이동합니다. 11.12.18 60 0
294926 형들 이 사이트 알아? 임베디드쪽 무료강의해주는곳인데 [2] ㅇㅇ(112.148) 11.12.18 123 0
294925 엄청 간단한 html인데 해결좀 도와주세요 ㅠ [3] 홈페이징(122.40) 11.12.18 74 0
294924 난 개발자가 되려고 취업을 알아보는데 [1] ㅋㅋㅋ(110.70) 11.12.18 89 0
294923 DB 쌩초짜 질문좀 할게!! ㅌㄹ(59.26) 11.12.18 34 0
294922 Sencha Touch 로 결정했다! 으이얍! [2] 캐센터닭(115.92) 11.12.18 78 0
294921 데이터베이스 뭐 좀 물어볼게요;;; [7] 전설의대지갤로그로 이동합니다. 11.12.18 85 0
294919 중소기업이나 벤처기업은 면접 떨어지면 문자로 통보해주나? [3] 123(211.48) 11.12.18 177 0
294918 13층에서 이사 왔다고 떡을 돌리는데 [3] 거칠게갤로그로 이동합니다. 11.12.18 107 0
294917 과제 질문염!!(BufferedReader관련) [5] 케이갤로그로 이동합니다. 11.12.18 75 0
294916 어셈블리 질문하나만 할께형들 젭라알려줘 [2] 파일입출력(1.216) 11.12.18 47 0
294915 MFC 좀 하눈사람들 일로와바!!!!!!!!!!!!!!!!!!!! [3] (220.116) 11.12.18 92 0
294914 혹시 가족같은 분위기의 IT업게 다니는 사람 있냐? [4] 므해?갤로그로 이동합니다. 11.12.18 174 0
294913 중국에서 하려니 느려 터져서 못해 먹겠네 [3] Mihark(123.125) 11.12.18 60 0
294912 취업했는데 맘에 안든다.. 어쩌지?? [3] ㄹㄹㄹ(110.70) 11.12.18 127 0
294911 스타2에서 최고의 명언 IT == 똥(182.211) 11.12.18 75 0
294910 컴계산기 x미지수 사용하는방법 아냐? (110.14) 11.12.18 36 0
294909 으하하하하하하 IT는 똥이야 똥~~!! IT == 똥(182.211) 11.12.18 46 0
294907 openkore 라고 아는 형 있어? ㅜ [4] 권리장전갤로그로 이동합니다. 11.12.18 73 0
294906 안드로이드폰 쓰는 횽들 어플 테스트좀!!! [27] 쿄스케갤로그로 이동합니다. 11.12.18 158 0
294905 자바프로그래밍 질문좀할게요 [3] 음디니(211.222) 11.12.18 43 0
294904 웹 제작에 관심 있는데 어디부터 시작해야 할까요? [4] 볼일같은잠(165.194) 11.12.18 95 0
294903 형님들 API 간단한거 물어보면 답해주셔요??? [1] 하하하호하갤로그로 이동합니다. 11.12.18 43 0
294902 싸지방에서,, DEV-C 코딩하는방법 일등병(124.194) 11.12.18 74 0
294901 20대 초중반의 아이티 관련업에 할려는 사람에게 [3] 므해?갤로그로 이동합니다. 11.12.18 179 0
294900 혹시 매가패스에서 바뀐 쿡 공유기 쓰는갤러있음? 김바비(220.82) 11.12.18 53 0
294899 가비지 컬랙션땜에 미치것네 [7] asdafasd(211.222) 11.12.18 125 0
294898 혹시 코딩할때 음악 들으면서 하는 사람 있음? [7] ㅌㄹ(59.26) 11.12.18 169 0
294897 JS 느님 찬양 합니다. 캐js닭(115.92) 11.12.18 55 0
294895 회사에 혼자 나와서 가슴이 두근두근 [1] 캐출근닭(115.92) 11.12.18 161 0
294894 과제 미치겠다 [1] 1111(124.195) 11.12.18 59 0
294893 오랜만에 혼자 코딩 땡칠도사갤로그로 이동합니다. 11.12.18 78 0
294892 cmd로 ftp접속해서 put으로 파일 업로드하려는데 [3] asdf(121.160) 11.12.18 105 0
294891 원빈으로 태어나기 vs 빌게이츠로 태어나기 [5] 금고래갤로그로 이동합니다. 11.12.18 137 0
294889 JSON 잘아는횽들!! [11] kkk(112.144) 11.12.18 110 0
294888 프갤이 참 좋아 [1] 주석없음갤로그로 이동합니다. 11.12.18 87 0
294887 형들중에 [1] 컴쏘갤로그로 이동합니다. 11.12.18 34 0
294886 네이트온 맥 버젼 써본 사람? [5] Mihark(123.125) 11.12.18 111 0
294885 삼진 탐색트린데요.... 전위 탐색하려고 하는데... [4] 차콜그레이갤로그로 이동합니다. 11.12.18 195 0
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

디시미디어

디시이슈

1/2