**** Solved thank you!
First off, I am very VERY new to Java and my college ended up going online for this class, so I having hard time on some things.
I have the following code, (see below). The issue is it will not return a new balance amount. I have tried many changes and cannot get it to work. If someone could please explain where I am messing up and why, I'd appreciate it.
package pkg05lab; import java.util.Scanner; public class AccountHolder { static Scanner sc = new Scanner(System.in); static double balance; public static void main(String args[]) { AccountHolder myAccount = new AccountHolder(); System.out.printf("Initial Balance is: %.2f%n%n", myAccount.getBalance()); System.out.println("Please enter the Balance: "); double newBalance = sc.nextDouble(); myAccount.setBalance(newBalance); System.out.printf("Amount in current Balance is: %.2f%n", myAccount.getBalance()); } private double newBalance; public void setBalance(double balance) { newBalance = balance; } public double getBalance() { return balance; } }
Output when run:
run:
Initial Balance is: 0.00
Please enter the Balance:
1234.56
Amount in current Balance is: 0.00
BUILD SUCCESSFUL (total time: 13 seconds)