Looking for a Programmer // Simple Bank Program

Discussion in 'Programming General' started by symphony888, Jan 15, 2013.

Looking for a Programmer // Simple Bank Program
  1. Unread #1 - Jan 15, 2013 at 8:57 AM
  2. symphony888
    Joined:
    May 30, 2010
    Posts:
    2,464
    Referrals:
    4
    Sythe Gold:
    0

    symphony888 Request a PM before trading! <3 Sythe.Org
    Banned

    Looking for a Programmer // Simple Bank Program

    Hello.

    I'm in need of help at the moment for my project. I'm stuck at a part that I don't know how to solve myself.
    It is regarding some outputs, arrays and some calculation.

    I can give more overview of the whole program if someone decides to help me out. I have programmed like almost close to half of it. But I need help in some areas.

    I hope someone is kind enough to help me out. Really in need of help.

    Thanks :)

    Add me [email protected]
     
  3. Unread #2 - Jan 15, 2013 at 9:08 AM
  4. iJava
    Joined:
    Nov 21, 2011
    Posts:
    1,197
    Referrals:
    11
    Sythe Gold:
    485
    Discord Unique ID:
    220055593568829441

    iJava .Previously known as RSGoldRush
    $200 USD Donor New

    Looking for a Programmer // Simple Bank Program

    Post code or something.
     
  5. Unread #3 - Jan 15, 2013 at 9:24 AM
  6. symphony888
    Joined:
    May 30, 2010
    Posts:
    2,464
    Referrals:
    4
    Sythe Gold:
    0

    symphony888 Request a PM before trading! <3 Sythe.Org
    Banned

    Looking for a Programmer // Simple Bank Program

    public static void main(String[] args) throws Exception
    {
    int choice =0;
    int i = 0;
    int j = 0;
    char decision = 'y';
    double[] depositA = new double[5];
    double[] withdrawA = new double[5];
    //double[] sum = new sum[10];


    while(choice != 4)
    {

    System.out.println("\t\t\tWelcome to TP's Bank");
    System.out.println("\t\t\t=====================");
    System.out.println("1. Deposit");
    System.out.println("2. Withdraw");
    System.out.println("3. Display all transacted records");
    System.out.println("4. Exit");
    System.out.print("Please select a choice or press 4 to Exit: ");
    choice = input.nextInt();


    switch(choice)
    {
    case 1: System.out.print("Key in the amount you wish to deposit: ");
    depositA = input.nextDouble();
    System.out.print("Confirm Y/N<?> ");
    decision = (char)System.in.read();
    System.in.read();
    System.in.read();
    i++;


    while(decision == 'N' || decision == 'n')
    {
    System.out.print("Key in the amount you wish to deposit: ");
    depositA = input.nextDouble();
    System.out.print("Confirm Y/N<?> ");
    decision = (char)System.in.read();
    System.in.read();
    System.in.read();
    i++;


    }

    //sum = (depositA + depositA);

    System.out.print("Thank you, you have deposited $"+fmt.format(depositA)+ " on ");
    System.out.println(new Timestamp(System.currentTimeMillis()));


    This is the part I'm stuck at. The fmt.format(depositA), doesn't capture what I typed when they asked how much I want to deposit. Rather it shows $0.00 at <timestamp>. But when I load transacted records(load the arrays), it shows as what I input like for example 300.

    Screenshot:
    [​IMG]

    As you can see there, I typed in 500, then typed in 'y' but it didn't record as $500.00, rather it is $0.00.
     
  7. Unread #4 - Jan 15, 2013 at 9:39 AM
  8. iJava
    Joined:
    Nov 21, 2011
    Posts:
    1,197
    Referrals:
    11
    Sythe Gold:
    485
    Discord Unique ID:
    220055593568829441

    iJava .Previously known as RSGoldRush
    $200 USD Donor New

    Looking for a Programmer // Simple Bank Program

    Try inputting 500.0
     
  9. Unread #5 - Jan 15, 2013 at 9:43 AM
  10. symphony888
    Joined:
    May 30, 2010
    Posts:
    2,464
    Referrals:
    4
    Sythe Gold:
    0

    symphony888 Request a PM before trading! <3 Sythe.Org
    Banned

    Looking for a Programmer // Simple Bank Program

    Nope. Still doesn't work.

    [​IMG]

    Must I make a while loop the char 'Y', so it corresponds to something ? or no ?
     
  11. Unread #6 - Jan 15, 2013 at 10:13 AM
  12. iJava
    Joined:
    Nov 21, 2011
    Posts:
    1,197
    Referrals:
    11
    Sythe Gold:
    485
    Discord Unique ID:
    220055593568829441

    iJava .Previously known as RSGoldRush
    $200 USD Donor New

    Looking for a Programmer // Simple Bank Program

    Oh just read it again, it's 4AM so forgive me, you're adding the value to array then adding one to i then reading it so it's like this.

    array[1] = nextDouble
    i++
    format(array[2])
     
  13. Unread #7 - Jan 15, 2013 at 12:37 PM
  14. Snoopchicken
    Joined:
    Jun 13, 2012
    Posts:
    383
    Referrals:
    0
    Sythe Gold:
    0

    Snoopchicken Forum Addict

    Looking for a Programmer // Simple Bank Program



    Yes, he's right. A quick fix would be to change this line:

    System.out.print("Thank you, you have deposited $"+fmt.format(depositA)+ " on ");

    Into this:

    System.out.print("Thank you, you have deposited $"+fmt.format(depositA[i-1])+ " on ");

    I underlined the change. Basically, change depositA to depositA[i-1]. Of course, it would be better for you to in fact change the entire logic of your program so this mistake doesn't happen in the first place.
     
  15. Unread #8 - Jan 15, 2013 at 7:12 PM
  16. symphony888
    Joined:
    May 30, 2010
    Posts:
    2,464
    Referrals:
    4
    Sythe Gold:
    0

    symphony888 Request a PM before trading! <3 Sythe.Org
    Banned

    Looking for a Programmer // Simple Bank Program

    Oh alright. That worked! Thanks a lot.

    Another question would be.

    From this output - [​IMG]

    You can see that the first value I input 600. But then I typed 'n', which means it is not supposed to be in the array itself as I did not confirmed 'y'.
    How do I remove that from my array output ?

    This is the part for my Case 3.

    case 3: System.out.println("=========================");
    System.out.println("Deposit Record");
    System.out.println("=========================");

    System.out.println("Date & Time\tAmount");
    for(int k=0; k<i; k++)
    {

    System.out.println("\t\t"+fmt.format(depositA[k]));

    }

    System.out.println("=========================");
    System.out.println("Withdraw Record");
    System.out.println("=========================");
    System.out.println("Date & Time\tAmount");
    for(int m=0; m<j; m++)
    {

    System.out.println("\t\t"+fmt.format(withdrawA[m]));
    }


    break;

    How do I fix that ? I'm still looking for a fix through the webs, but still can't find nothing.
     
  17. Unread #9 - Jan 16, 2013 at 11:06 PM
  18. iJava
    Joined:
    Nov 21, 2011
    Posts:
    1,197
    Referrals:
    11
    Sythe Gold:
    485
    Discord Unique ID:
    220055593568829441

    iJava .Previously known as RSGoldRush
    $200 USD Donor New

    Looking for a Programmer // Simple Bank Program

    Do something like :

    if(decision.equals('Y')) {
    array = 0;

    ...


    if(array[j] == 0) {
    continue;
    }
    fmt.format(array[j]);
     
  19. Unread #10 - Jan 17, 2013 at 6:37 AM
  20. symphony888
    Joined:
    May 30, 2010
    Posts:
    2,464
    Referrals:
    4
    Sythe Gold:
    0

    symphony888 Request a PM before trading! <3 Sythe.Org
    Banned

    Looking for a Programmer // Simple Bank Program

    Alright thanks ! I've got 90% of the program working. Just left with the timestamp and store it in the array.
     
  21. Unread #11 - Jan 17, 2013 at 2:57 PM
  22. iJava
    Joined:
    Nov 21, 2011
    Posts:
    1,197
    Referrals:
    11
    Sythe Gold:
    485
    Discord Unique ID:
    220055593568829441

    iJava .Previously known as RSGoldRush
    $200 USD Donor New

    Looking for a Programmer // Simple Bank Program

    You're going to have to do a 2D array or create your own class then.
     
  23. Unread #12 - Jan 17, 2013 at 8:11 PM
  24. symphony888
    Joined:
    May 30, 2010
    Posts:
    2,464
    Referrals:
    4
    Sythe Gold:
    0

    symphony888 Request a PM before trading! <3 Sythe.Org
    Banned

    Looking for a Programmer // Simple Bank Program

    What would be the best library to use for timestamp ?

    I've got the format of how I want the Date to be. Now I'm left with the timestamp and then I need to store those in the array and when I load the transacted records, it will show Date/Time if me doing the Deposit and Withdraw.
     
  25. Unread #13 - Jan 17, 2013 at 10:16 PM
  26. SuF
    Joined:
    Jan 21, 2007
    Posts:
    14,212
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary

    SuF Legend
    Pirate Retired Global Moderator

    Looking for a Programmer // Simple Bank Program

    Use code tags! [code]putcodeinhere[/code]
     
  27. Unread #14 - Jan 18, 2013 at 9:46 AM
  28. RuneScapeJJ
    Joined:
    Aug 14, 2011
    Posts:
    1,522
    Referrals:
    1
    Sythe Gold:
    0
    Potamus

    RuneScapeJJ Guru
    $25 USD Donor New

    Looking for a Programmer // Simple Bank Program

    Would use something like this for the date etc.
    Code:
    	// Returns the calendar data as a String
    	private String getDate(){
    		SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyy HH-mm-ss");
    		Date date = new Date();
    		return sdf.format(date);
    	}
     
  29. Unread #15 - Jan 19, 2013 at 9:01 AM
  30. symphony888
    Joined:
    May 30, 2010
    Posts:
    2,464
    Referrals:
    4
    Sythe Gold:
    0

    symphony888 Request a PM before trading! <3 Sythe.Org
    Banned

    Looking for a Programmer // Simple Bank Program

    So do I just call the method in when I want the date and time to be output ?
     
  31. Unread #16 - Jan 19, 2013 at 1:55 PM
  32. RuneScapeJJ
    Joined:
    Aug 14, 2011
    Posts:
    1,522
    Referrals:
    1
    Sythe Gold:
    0
    Potamus

    RuneScapeJJ Guru
    $25 USD Donor New

    Looking for a Programmer // Simple Bank Program

    When you call the method it returns a String in this format: dd-MM-yyy HH-mm-ss

    So right now where I live that would be
    19-01-2013 19-54-06

    You can also make it 19:54:06 but those are invalid characters for text files, which is where I used it for.

    Some country's like to put the month first so to get like 01-19-2013 19:55:16 you would do

    Code:
    // Returns the calendar data as a String
    	private String getDate(){
    		SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyy HH:mm:ss");
    		Date date = new Date();
    		return sdf.format(date);
    	}
    EDIT: you can also make it one line and more efficient if you want
    Code:
    return new SimpleDateFormat("MM-dd-yyy HH:mm:ss").format(new Date());
     
  33. Unread #17 - Jan 21, 2013 at 5:28 AM
  34. symphony888
    Joined:
    May 30, 2010
    Posts:
    2,464
    Referrals:
    4
    Sythe Gold:
    0

    symphony888 Request a PM before trading! <3 Sythe.Org
    Banned

    Looking for a Programmer // Simple Bank Program

    So what I would do would be like

    Code:
     if(int i = 0; i>0; i++)
    {
    System.out.println(getdate);
    }
    
    ?
     
  35. Unread #18 - Jan 24, 2013 at 8:01 PM
  36. symphony888
    Joined:
    May 30, 2010
    Posts:
    2,464
    Referrals:
    4
    Sythe Gold:
    0

    symphony888 Request a PM before trading! <3 Sythe.Org
    Banned

    Looking for a Programmer // Simple Bank Program

    Alright I got it fixed already.

    Now, I'm wondering how do I put that getDate or rather the timestamp(date + time) into an array itself ? I've been trying several ways to put it in an array. But still, the results weren't right.
     
  37. Unread #19 - Jan 24, 2013 at 8:40 PM
  38. blindkilla
    Joined:
    Jun 22, 2005
    Posts:
    1,896
    Referrals:
    0
    Sythe Gold:
    6
    Discord Unique ID:
    282000633404456960
    Discord Username:
    sogord

    blindkilla Guru
    $25 USD Donor New

    Looking for a Programmer // Simple Bank Program

  39. Unread #20 - Jan 25, 2013 at 3:26 AM
  40. symphony888
    Joined:
    May 30, 2010
    Posts:
    2,464
    Referrals:
    4
    Sythe Gold:
    0

    symphony888 Request a PM before trading! <3 Sythe.Org
    Banned

    Looking for a Programmer // Simple Bank Program

    Thanks, I will need to understand that though. Still figuring out.
     
< [Python] Facebook Archive Message Splitter | Java homework help >

Users viewing this thread
1 guest


 
 
Adblock breaks this site