Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi! I'm taking my first java class, and am having a hard time with the latest homework assignment. I'm to use an input on loop so the user enters a series of numbers. These numbers in turn need to be used to print out their banking transactions (very basic, just anything that was positive will be a deposit, anything they entered as negative will show as a withdrawal.) The problem is with the "balance" - how do I get a user input to correlate in terms of sums on the balance print out, if I didn't ask for each transaction separately (with a different variable)?
Here's my code so far:
import java.util.Scanner; // program uses class Scanner
public class x {//main method
public static void main( String args[] ){
// create scanner
Scanner input = new Scanner(System.in);
int i = input.nextInt();
while (i != 0){
for (i = 1; i <=10; i++){
System.out.print("\nFirst enter your balance, transactions for the last 30 days and end with 0:");
i = input.nextInt();
if (i == 0)
break;
}
}
}
}How do I use each input in a printf statement? Or am I totally off the mark here?
Thanks!
P.S. I also realized that it's not reading my for count either. hmmm...

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |