• Log in or sign up for an account here: https://www.sythe.org/login

Looking for a Programmer // Simple Bank Program

symphony888

Request a PM before trading! <3 Sythe.Org

Banned
Joined
May 30, 2010
Sythe Gold
0
Messages
2,464
Age
33
Location
Sythe.org
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]
 
PHP Shit Show 2k26
Post code or something.
 
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:
1O3rX


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.
 
PHP Shit Show 2k26
Try inputting 500.0
 
Nope. Still doesn't work.

1O3Kf


Must I make a while loop the char 'Y', so it corresponds to something ? or no ?
 
PHP Shit Show 2k26
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])
 
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])


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.
 
Oh alright. That worked! Thanks a lot.

Another question would be.

From this output -
1Oe9g


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.
 
PHP Shit Show 2k26
Do something like :

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

...


if(array[j] == 0) {
continue;
}
fmt.format(array[j]);
 
Alright thanks ! I've got 90% of the program working. Just left with the timestamp and store it in the array.
 
PHP Shit Show 2k26
Alright thanks ! I've got 90% of the program working. Just left with the timestamp and store it in the array.

You're going to have to do a 2D array or create your own class then.
 
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.
 
<3 n4n0
Discord Verified
Two Factor Authentication User
Community Participant
Spam Forum Participant
Sythe's 10th Anniversary
Sythe Awards 2011 Winner
Use code tags! [code]putcodeinhere[/code]
 
Potamus
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);
	}
 
So do I just call the method in when I want the date and time to be output ?
 
Potamus
So do I just call the method in when I want the date and time to be output ?
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());
 
So what I would do would be like

Code:
 if(int i = 0; i>0; i++)
{
System.out.println(getdate);
}

?
 
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.
 
Runescape Gamblingrunescape gambling
Back
Top