SlideShare a Scribd company logo
You are not setting any values for those variables(name, ID, interestRate, balance) when you
create the object. Hence, they are instantiated to 0 or null based on the type.
Add this to the main method:
String name = "Jonathan"; //any value
int ID = 22; //any value
double interestRate = 10.2; //any value
double balance = 100000.0 //any value
Hence, your final program should look like this:
import java.util.Scanner;
public class BankAccount
{
public BankAccount()
{
setName("");
setID(0);
setBalance(0);
setInterestRate(0);
}
public BankAccount(String name, int ID, double balance, double interestRate)
{
setName(name);
setID(ID);
setBalance(balance);
setInterestRate(interestRate);
}
//name
private static String name;
public void setName (String Name)
{
this.name = name;
}
public String getName()
{
return name;
}
//ID
private static int ID;
public void setID (int ID)
{
this.ID = ID;
}
public int getID()
{
return ID;
}
//balance
private static double balance;
public void setBalance (double balance)
{
this.balance = balance;
}
public double getBalance()
{
return balance;
}
//interest rate
static double interestRate;
public void setInterestRate (double interestrate)
{
this.interestRate = interestRate;
}
public double getInterestRate()
{
return interestRate;
}
//new account
public static void newAccount()
{
Scanner scan = new Scanner(System.in);
System.out.println("Hello new bank user! "
+ "Welcome to the Bank of Jonathan!");
//Have user input their name
System.out.print("Please enter your name:  ");
name = scan.nextLine();
//An account ID (stored as text)
System.out.print("Please enter your Bank ID:  ");
ID = scan.nextInt();
}
//my account
public static void myAccount()
{
Scanner scan = new Scanner(System.in);
System.out.println("Welcome to the Bank of Jonathan!");
//Have user input their name
System.out.print("Please enter your name:  ");
name = scan.nextLine();
//An account ID (stored as text)
System.out.print("Please enter your Bank ID:  ");
ID = scan.nextInt();
double myBalance = 10000;
balance = myBalance;
}
// //*Two constructors
// //*1)Takes an initial Balance
// public BankAccount(String inputName, int inputID, double initialBalance)
// {
// name = inputName;
// ID = inputID;
// balance = initialBalance;
//
// //System.out.println("Name: "
// //+ inputName);
// //System.out.println("The Intial balance is: "
// //+ inputID);
// //System.out.println("The Intial balance is: "
// //+ initialBalance);
// }
//
// //*2)Opens a new account with no money
// // public BankAccount()
// // {
// // balance = 0.00;
// // }
//A Deposit Method
public static void deposit()
{
Scanner scan = new Scanner(System.in);
System.out.printf("How much would you like to deposit? "
+ "Enter amount here: $");
double depositAmount = scan.nextDouble();
while(depositAmount <= 0.00)
{
System.out.println("Invalid deposit amount!");
System.out.printf("How much would you like to deposit? "
+ "Enter amount here: $");
depositAmount = scan.nextDouble();
}
balance += depositAmount;
System.out.println("The amount you deposited: $"
+ depositAmount + ". Your current balance: $"+ balance );
}
//A Withdrawal Method
public static void withdraw()
{
Scanner scan = new Scanner(System.in);
System.out.printf("How much would you like to withdraw? "
+ "Enter amount here: $");
double withdrawAmount = scan.nextDouble();
while(withdrawAmount <= 0.00)
{
System.out.println("Invalid withdrawal amount! "
+ "How much would you like to withdraw? "
+ "Enter amount here: $");
withdrawAmount = scan.nextDouble();
}
while(withdrawAmount > balance)
{
System.out.println("The balance you want to withdraw "
+ "is less than what you currently have in "
+ "this account! How much would you like to "
+ "withdraw?" + "Enter amount here: $");
withdrawAmount = scan.nextDouble();
}
balance -= withdrawAmount;
System.out.println("The amount you withdrew: $"+
withdrawAmount + ".  Your current balance: $"
+ balance );
}
//Interest Rate
public static void addInterestRate()
{
Scanner scan = new Scanner(System.in);
System.out.println("How much would you like to adjust "
+ "the % interest rate by?  Enter % amount here: ");
double updateInterestRate = scan.nextDouble();
interestRate += updateInterestRate;
balance += (balance * (interestRate / 100));
System.out.println("Current balance is now: $" + balance + " "
+ "With " + interestRate + "%");
}
//A toString Method
// public String toString()
// {
// BankAccount bankObject = new BankAccount(name, ID, interestRate, balance);
// System.out.printf("Name: ", bankObject.getName());
// System.out.printf("ID: ", bankObject.getID());
// System.out.printf("Interest Rate: ", bankObject.getInterestRate() + "%");
// System.out.printf("Balance: %", bankObject.getBalance());
//
//
// return "account";
// }
//Driver Program
public static void main(String[] args)
{
//newAccount();
//myAccount();
//deposit();
//withdraw();
//addInterestRate();
String name = "Jonathan"; //any value
int ID = 22; //any value
double interestRate = 10.2; //any value
double balance = 100000.0 //any value
BankAccount bankObject = new BankAccount(name, ID, interestRate, balance);
System.out.println("Name: " + bankObject.getName());
System.out.println("ID: " + bankObject.getID());
System.out.println("Interest Rate: " + bankObject.getInterestRate() + "%");
System.out.println("Balance: $" + bankObject.getBalance());
}
}
Solution
You are not setting any values for those variables(name, ID, interestRate, balance) when you
create the object. Hence, they are instantiated to 0 or null based on the type.
Add this to the main method:
String name = "Jonathan"; //any value
int ID = 22; //any value
double interestRate = 10.2; //any value
double balance = 100000.0 //any value
Hence, your final program should look like this:
import java.util.Scanner;
public class BankAccount
{
public BankAccount()
{
setName("");
setID(0);
setBalance(0);
setInterestRate(0);
}
public BankAccount(String name, int ID, double balance, double interestRate)
{
setName(name);
setID(ID);
setBalance(balance);
setInterestRate(interestRate);
}
//name
private static String name;
public void setName (String Name)
{
this.name = name;
}
public String getName()
{
return name;
}
//ID
private static int ID;
public void setID (int ID)
{
this.ID = ID;
}
public int getID()
{
return ID;
}
//balance
private static double balance;
public void setBalance (double balance)
{
this.balance = balance;
}
public double getBalance()
{
return balance;
}
//interest rate
static double interestRate;
public void setInterestRate (double interestrate)
{
this.interestRate = interestRate;
}
public double getInterestRate()
{
return interestRate;
}
//new account
public static void newAccount()
{
Scanner scan = new Scanner(System.in);
System.out.println("Hello new bank user! "
+ "Welcome to the Bank of Jonathan!");
//Have user input their name
System.out.print("Please enter your name:  ");
name = scan.nextLine();
//An account ID (stored as text)
System.out.print("Please enter your Bank ID:  ");
ID = scan.nextInt();
}
//my account
public static void myAccount()
{
Scanner scan = new Scanner(System.in);
System.out.println("Welcome to the Bank of Jonathan!");
//Have user input their name
System.out.print("Please enter your name:  ");
name = scan.nextLine();
//An account ID (stored as text)
System.out.print("Please enter your Bank ID:  ");
ID = scan.nextInt();
double myBalance = 10000;
balance = myBalance;
}
// //*Two constructors
// //*1)Takes an initial Balance
// public BankAccount(String inputName, int inputID, double initialBalance)
// {
// name = inputName;
// ID = inputID;
// balance = initialBalance;
//
// //System.out.println("Name: "
// //+ inputName);
// //System.out.println("The Intial balance is: "
// //+ inputID);
// //System.out.println("The Intial balance is: "
// //+ initialBalance);
// }
//
// //*2)Opens a new account with no money
// // public BankAccount()
// // {
// // balance = 0.00;
// // }
//A Deposit Method
public static void deposit()
{
Scanner scan = new Scanner(System.in);
System.out.printf("How much would you like to deposit? "
+ "Enter amount here: $");
double depositAmount = scan.nextDouble();
while(depositAmount <= 0.00)
{
System.out.println("Invalid deposit amount!");
System.out.printf("How much would you like to deposit? "
+ "Enter amount here: $");
depositAmount = scan.nextDouble();
}
balance += depositAmount;
System.out.println("The amount you deposited: $"
+ depositAmount + ". Your current balance: $"+ balance );
}
//A Withdrawal Method
public static void withdraw()
{
Scanner scan = new Scanner(System.in);
System.out.printf("How much would you like to withdraw? "
+ "Enter amount here: $");
double withdrawAmount = scan.nextDouble();
while(withdrawAmount <= 0.00)
{
System.out.println("Invalid withdrawal amount! "
+ "How much would you like to withdraw? "
+ "Enter amount here: $");
withdrawAmount = scan.nextDouble();
}
while(withdrawAmount > balance)
{
System.out.println("The balance you want to withdraw "
+ "is less than what you currently have in "
+ "this account! How much would you like to "
+ "withdraw?" + "Enter amount here: $");
withdrawAmount = scan.nextDouble();
}
balance -= withdrawAmount;
System.out.println("The amount you withdrew: $"+
withdrawAmount + ".  Your current balance: $"
+ balance );
}
//Interest Rate
public static void addInterestRate()
{
Scanner scan = new Scanner(System.in);
System.out.println("How much would you like to adjust "
+ "the % interest rate by?  Enter % amount here: ");
double updateInterestRate = scan.nextDouble();
interestRate += updateInterestRate;
balance += (balance * (interestRate / 100));
System.out.println("Current balance is now: $" + balance + " "
+ "With " + interestRate + "%");
}
//A toString Method
// public String toString()
// {
// BankAccount bankObject = new BankAccount(name, ID, interestRate, balance);
// System.out.printf("Name: ", bankObject.getName());
// System.out.printf("ID: ", bankObject.getID());
// System.out.printf("Interest Rate: ", bankObject.getInterestRate() + "%");
// System.out.printf("Balance: %", bankObject.getBalance());
//
//
// return "account";
// }
//Driver Program
public static void main(String[] args)
{
//newAccount();
//myAccount();
//deposit();
//withdraw();
//addInterestRate();
String name = "Jonathan"; //any value
int ID = 22; //any value
double interestRate = 10.2; //any value
double balance = 100000.0 //any value
BankAccount bankObject = new BankAccount(name, ID, interestRate, balance);
System.out.println("Name: " + bankObject.getName());
System.out.println("ID: " + bankObject.getID());
System.out.println("Interest Rate: " + bankObject.getInterestRate() + "%");
System.out.println("Balance: $" + bankObject.getBalance());
}
}

More Related Content

Similar to You are not setting any values for those variables(name, ID, interes.pdf

Please distinguish between the .h and .cpp file, create a fully work.pdf
Please distinguish between the .h and .cpp file, create a fully work.pdfPlease distinguish between the .h and .cpp file, create a fully work.pdf
Please distinguish between the .h and .cpp file, create a fully work.pdf
neerajsachdeva33
 
Interest.javaimport java.util.Scanner; public class Interest.pdf
 Interest.javaimport java.util.Scanner; public class Interest.pdf Interest.javaimport java.util.Scanner; public class Interest.pdf
Interest.javaimport java.util.Scanner; public class Interest.pdf
aradhana9856
 
public class InsufficientFundsException extends Exception{Insuffic.pdf
public class InsufficientFundsException extends Exception{Insuffic.pdfpublic class InsufficientFundsException extends Exception{Insuffic.pdf
public class InsufficientFundsException extends Exception{Insuffic.pdf
ankitcom
 
07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt
Ajenkris Kungkung
 
Javascript & jQuery: A pragmatic introduction
Javascript & jQuery: A pragmatic introductionJavascript & jQuery: A pragmatic introduction
Javascript & jQuery: A pragmatic introduction
Iban Martinez
 
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdfC++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
JUSTSTYLISH3B2MOHALI
 
import java.util.Scanner;import java.text.DecimalFormat;import j.pdf
import java.util.Scanner;import java.text.DecimalFormat;import j.pdfimport java.util.Scanner;import java.text.DecimalFormat;import j.pdf
import java.util.Scanner;import java.text.DecimalFormat;import j.pdf
KUNALHARCHANDANI1
 
Please observe the the code and validations of user inputs.import .pdf
Please observe the the code and validations of user inputs.import .pdfPlease observe the the code and validations of user inputs.import .pdf
Please observe the the code and validations of user inputs.import .pdf
apexjaipur
 
Tmpj3 01 201181102muhammad_tohir
Tmpj3 01 201181102muhammad_tohirTmpj3 01 201181102muhammad_tohir
Tmpj3 01 201181102muhammad_tohir
pencari buku
 
Account.h Definition of Account class. #ifndef ACCOUNT_H #d.pdf
Account.h  Definition of Account class. #ifndef ACCOUNT_H #d.pdfAccount.h  Definition of Account class. #ifndef ACCOUNT_H #d.pdf
Account.h Definition of Account class. #ifndef ACCOUNT_H #d.pdf
anujmkt
 
help me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdfhelp me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdf
arihantmum
 
Jva
Jva Jva
Need help finding the error in my code. Wherever theres a player.pdf
Need help finding the error in my code. Wherever theres a player.pdfNeed help finding the error in my code. Wherever theres a player.pdf
Need help finding the error in my code. Wherever theres a player.pdf
arihanthtoysandgifts
 

Similar to You are not setting any values for those variables(name, ID, interes.pdf (13)

Please distinguish between the .h and .cpp file, create a fully work.pdf
Please distinguish between the .h and .cpp file, create a fully work.pdfPlease distinguish between the .h and .cpp file, create a fully work.pdf
Please distinguish between the .h and .cpp file, create a fully work.pdf
 
Interest.javaimport java.util.Scanner; public class Interest.pdf
 Interest.javaimport java.util.Scanner; public class Interest.pdf Interest.javaimport java.util.Scanner; public class Interest.pdf
Interest.javaimport java.util.Scanner; public class Interest.pdf
 
public class InsufficientFundsException extends Exception{Insuffic.pdf
public class InsufficientFundsException extends Exception{Insuffic.pdfpublic class InsufficientFundsException extends Exception{Insuffic.pdf
public class InsufficientFundsException extends Exception{Insuffic.pdf
 
07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt
 
Javascript & jQuery: A pragmatic introduction
Javascript & jQuery: A pragmatic introductionJavascript & jQuery: A pragmatic introduction
Javascript & jQuery: A pragmatic introduction
 
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdfC++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
C++ Bank Account Error Fix, full code. I am using Dev-C++ to Compile.pdf
 
import java.util.Scanner;import java.text.DecimalFormat;import j.pdf
import java.util.Scanner;import java.text.DecimalFormat;import j.pdfimport java.util.Scanner;import java.text.DecimalFormat;import j.pdf
import java.util.Scanner;import java.text.DecimalFormat;import j.pdf
 
Please observe the the code and validations of user inputs.import .pdf
Please observe the the code and validations of user inputs.import .pdfPlease observe the the code and validations of user inputs.import .pdf
Please observe the the code and validations of user inputs.import .pdf
 
Tmpj3 01 201181102muhammad_tohir
Tmpj3 01 201181102muhammad_tohirTmpj3 01 201181102muhammad_tohir
Tmpj3 01 201181102muhammad_tohir
 
Account.h Definition of Account class. #ifndef ACCOUNT_H #d.pdf
Account.h  Definition of Account class. #ifndef ACCOUNT_H #d.pdfAccount.h  Definition of Account class. #ifndef ACCOUNT_H #d.pdf
Account.h Definition of Account class. #ifndef ACCOUNT_H #d.pdf
 
help me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdfhelp me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdf
 
Jva
Jva Jva
Jva
 
Need help finding the error in my code. Wherever theres a player.pdf
Need help finding the error in my code. Wherever theres a player.pdfNeed help finding the error in my code. Wherever theres a player.pdf
Need help finding the error in my code. Wherever theres a player.pdf
 

More from deepakangel

True Reason In more concentrated solution, hyd.pdf
                     True  Reason  In more concentrated solution, hyd.pdf                     True  Reason  In more concentrated solution, hyd.pdf
True Reason In more concentrated solution, hyd.pdf
deepakangel
 
Since the electrons from Zn gets transferred to F.pdf
                     Since the electrons from Zn gets transferred to F.pdf                     Since the electrons from Zn gets transferred to F.pdf
Since the electrons from Zn gets transferred to F.pdf
deepakangel
 
Lewis Acid Base Theory .pdf
                     Lewis Acid Base Theory                           .pdf                     Lewis Acid Base Theory                           .pdf
Lewis Acid Base Theory .pdf
deepakangel
 
I3+ Solu.pdf
                     I3+                                      Solu.pdf                     I3+                                      Solu.pdf
I3+ Solu.pdf
deepakangel
 
Yes its is correctly solved. P1 (Frequency of population) is done wi.pdf
Yes its is correctly solved. P1 (Frequency of population) is done wi.pdfYes its is correctly solved. P1 (Frequency of population) is done wi.pdf
Yes its is correctly solved. P1 (Frequency of population) is done wi.pdf
deepakangel
 
Total H+ ion concentration in the solution = H+ of HCl + H+ of water.pdf
Total H+ ion concentration in the solution = H+ of HCl + H+ of water.pdfTotal H+ ion concentration in the solution = H+ of HCl + H+ of water.pdf
Total H+ ion concentration in the solution = H+ of HCl + H+ of water.pdf
deepakangel
 
The genomic library includes introns and promotors. However, in cDNA.pdf
The genomic library includes introns and promotors. However, in cDNA.pdfThe genomic library includes introns and promotors. However, in cDNA.pdf
The genomic library includes introns and promotors. However, in cDNA.pdf
deepakangel
 
Halfway titration Half of the base is neutralise.pdf
                     Halfway titration Half of the base is neutralise.pdf                     Halfway titration Half of the base is neutralise.pdf
Halfway titration Half of the base is neutralise.pdf
deepakangel
 
The HTML canvas element is used to draw graphics on a web page.T.pdf
The HTML canvas element is used to draw graphics on a web page.T.pdfThe HTML canvas element is used to draw graphics on a web page.T.pdf
The HTML canvas element is used to draw graphics on a web page.T.pdf
deepakangel
 
Fluorescein has a OH group and a COOH group. If a.pdf
                     Fluorescein has a OH group and a COOH group. If a.pdf                     Fluorescein has a OH group and a COOH group. If a.pdf
Fluorescein has a OH group and a COOH group. If a.pdf
deepakangel
 
Solution 3Capital = Total Assets – Current Liabilities          .pdf
Solution 3Capital = Total Assets – Current Liabilities          .pdfSolution 3Capital = Total Assets – Current Liabilities          .pdf
Solution 3Capital = Total Assets – Current Liabilities          .pdf
deepakangel
 
Q1ROMThe boot loader basically put Hex code into already there .pdf
Q1ROMThe boot loader basically put Hex code into already there .pdfQ1ROMThe boot loader basically put Hex code into already there .pdf
Q1ROMThe boot loader basically put Hex code into already there .pdf
deepakangel
 
Raising the temperature changes the solubility of a substance in wat.pdf
Raising the temperature changes the solubility of a substance in wat.pdfRaising the temperature changes the solubility of a substance in wat.pdf
Raising the temperature changes the solubility of a substance in wat.pdf
deepakangel
 
MAN pages.These pages describes commands functions and there prope.pdf
MAN pages.These pages describes commands functions and there prope.pdfMAN pages.These pages describes commands functions and there prope.pdf
MAN pages.These pages describes commands functions and there prope.pdf
deepakangel
 
If a person has inability to present antigens to Tc cells (cytotoxic.pdf
If a person has inability to present antigens to Tc cells (cytotoxic.pdfIf a person has inability to present antigens to Tc cells (cytotoxic.pdf
If a person has inability to present antigens to Tc cells (cytotoxic.pdf
deepakangel
 
i didnt get your question its unclear do you mean conjunctive .pdf
i didnt get your question its unclear do you mean conjunctive .pdfi didnt get your question its unclear do you mean conjunctive .pdf
i didnt get your question its unclear do you mean conjunctive .pdf
deepakangel
 
Here is the code with comments for the question. Sample output is al.pdf
Here is the code with comments for the question. Sample output is al.pdfHere is the code with comments for the question. Sample output is al.pdf
Here is the code with comments for the question. Sample output is al.pdf
deepakangel
 
Embedded systemIt is a computer system with a dedicated function .pdf
Embedded systemIt is a computer system with a dedicated function .pdfEmbedded systemIt is a computer system with a dedicated function .pdf
Embedded systemIt is a computer system with a dedicated function .pdf
deepakangel
 
Factors.javaimport java.io.; import java.util.Scanner; class .pdf
Factors.javaimport java.io.; import java.util.Scanner; class .pdfFactors.javaimport java.io.; import java.util.Scanner; class .pdf
Factors.javaimport java.io.; import java.util.Scanner; class .pdf
deepakangel
 
couldnt sloveSolutioncouldnt slove.pdf
couldnt sloveSolutioncouldnt slove.pdfcouldnt sloveSolutioncouldnt slove.pdf
couldnt sloveSolutioncouldnt slove.pdf
deepakangel
 

More from deepakangel (20)

True Reason In more concentrated solution, hyd.pdf
                     True  Reason  In more concentrated solution, hyd.pdf                     True  Reason  In more concentrated solution, hyd.pdf
True Reason In more concentrated solution, hyd.pdf
 
Since the electrons from Zn gets transferred to F.pdf
                     Since the electrons from Zn gets transferred to F.pdf                     Since the electrons from Zn gets transferred to F.pdf
Since the electrons from Zn gets transferred to F.pdf
 
Lewis Acid Base Theory .pdf
                     Lewis Acid Base Theory                           .pdf                     Lewis Acid Base Theory                           .pdf
Lewis Acid Base Theory .pdf
 
I3+ Solu.pdf
                     I3+                                      Solu.pdf                     I3+                                      Solu.pdf
I3+ Solu.pdf
 
Yes its is correctly solved. P1 (Frequency of population) is done wi.pdf
Yes its is correctly solved. P1 (Frequency of population) is done wi.pdfYes its is correctly solved. P1 (Frequency of population) is done wi.pdf
Yes its is correctly solved. P1 (Frequency of population) is done wi.pdf
 
Total H+ ion concentration in the solution = H+ of HCl + H+ of water.pdf
Total H+ ion concentration in the solution = H+ of HCl + H+ of water.pdfTotal H+ ion concentration in the solution = H+ of HCl + H+ of water.pdf
Total H+ ion concentration in the solution = H+ of HCl + H+ of water.pdf
 
The genomic library includes introns and promotors. However, in cDNA.pdf
The genomic library includes introns and promotors. However, in cDNA.pdfThe genomic library includes introns and promotors. However, in cDNA.pdf
The genomic library includes introns and promotors. However, in cDNA.pdf
 
Halfway titration Half of the base is neutralise.pdf
                     Halfway titration Half of the base is neutralise.pdf                     Halfway titration Half of the base is neutralise.pdf
Halfway titration Half of the base is neutralise.pdf
 
The HTML canvas element is used to draw graphics on a web page.T.pdf
The HTML canvas element is used to draw graphics on a web page.T.pdfThe HTML canvas element is used to draw graphics on a web page.T.pdf
The HTML canvas element is used to draw graphics on a web page.T.pdf
 
Fluorescein has a OH group and a COOH group. If a.pdf
                     Fluorescein has a OH group and a COOH group. If a.pdf                     Fluorescein has a OH group and a COOH group. If a.pdf
Fluorescein has a OH group and a COOH group. If a.pdf
 
Solution 3Capital = Total Assets – Current Liabilities          .pdf
Solution 3Capital = Total Assets – Current Liabilities          .pdfSolution 3Capital = Total Assets – Current Liabilities          .pdf
Solution 3Capital = Total Assets – Current Liabilities          .pdf
 
Q1ROMThe boot loader basically put Hex code into already there .pdf
Q1ROMThe boot loader basically put Hex code into already there .pdfQ1ROMThe boot loader basically put Hex code into already there .pdf
Q1ROMThe boot loader basically put Hex code into already there .pdf
 
Raising the temperature changes the solubility of a substance in wat.pdf
Raising the temperature changes the solubility of a substance in wat.pdfRaising the temperature changes the solubility of a substance in wat.pdf
Raising the temperature changes the solubility of a substance in wat.pdf
 
MAN pages.These pages describes commands functions and there prope.pdf
MAN pages.These pages describes commands functions and there prope.pdfMAN pages.These pages describes commands functions and there prope.pdf
MAN pages.These pages describes commands functions and there prope.pdf
 
If a person has inability to present antigens to Tc cells (cytotoxic.pdf
If a person has inability to present antigens to Tc cells (cytotoxic.pdfIf a person has inability to present antigens to Tc cells (cytotoxic.pdf
If a person has inability to present antigens to Tc cells (cytotoxic.pdf
 
i didnt get your question its unclear do you mean conjunctive .pdf
i didnt get your question its unclear do you mean conjunctive .pdfi didnt get your question its unclear do you mean conjunctive .pdf
i didnt get your question its unclear do you mean conjunctive .pdf
 
Here is the code with comments for the question. Sample output is al.pdf
Here is the code with comments for the question. Sample output is al.pdfHere is the code with comments for the question. Sample output is al.pdf
Here is the code with comments for the question. Sample output is al.pdf
 
Embedded systemIt is a computer system with a dedicated function .pdf
Embedded systemIt is a computer system with a dedicated function .pdfEmbedded systemIt is a computer system with a dedicated function .pdf
Embedded systemIt is a computer system with a dedicated function .pdf
 
Factors.javaimport java.io.; import java.util.Scanner; class .pdf
Factors.javaimport java.io.; import java.util.Scanner; class .pdfFactors.javaimport java.io.; import java.util.Scanner; class .pdf
Factors.javaimport java.io.; import java.util.Scanner; class .pdf
 
couldnt sloveSolutioncouldnt slove.pdf
couldnt sloveSolutioncouldnt slove.pdfcouldnt sloveSolutioncouldnt slove.pdf
couldnt sloveSolutioncouldnt slove.pdf
 

Recently uploaded

The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 

Recently uploaded (20)

The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 

You are not setting any values for those variables(name, ID, interes.pdf

  • 1. You are not setting any values for those variables(name, ID, interestRate, balance) when you create the object. Hence, they are instantiated to 0 or null based on the type. Add this to the main method: String name = "Jonathan"; //any value int ID = 22; //any value double interestRate = 10.2; //any value double balance = 100000.0 //any value Hence, your final program should look like this: import java.util.Scanner; public class BankAccount { public BankAccount() { setName(""); setID(0); setBalance(0); setInterestRate(0); } public BankAccount(String name, int ID, double balance, double interestRate) { setName(name); setID(ID); setBalance(balance); setInterestRate(interestRate); } //name private static String name; public void setName (String Name) { this.name = name; } public String getName() { return name; }
  • 2. //ID private static int ID; public void setID (int ID) { this.ID = ID; } public int getID() { return ID; } //balance private static double balance; public void setBalance (double balance) { this.balance = balance; } public double getBalance() { return balance; } //interest rate static double interestRate; public void setInterestRate (double interestrate) { this.interestRate = interestRate; } public double getInterestRate() { return interestRate; } //new account public static void newAccount() { Scanner scan = new Scanner(System.in); System.out.println("Hello new bank user! " + "Welcome to the Bank of Jonathan!");
  • 3. //Have user input their name System.out.print("Please enter your name: "); name = scan.nextLine(); //An account ID (stored as text) System.out.print("Please enter your Bank ID: "); ID = scan.nextInt(); } //my account public static void myAccount() { Scanner scan = new Scanner(System.in); System.out.println("Welcome to the Bank of Jonathan!"); //Have user input their name System.out.print("Please enter your name: "); name = scan.nextLine(); //An account ID (stored as text) System.out.print("Please enter your Bank ID: "); ID = scan.nextInt(); double myBalance = 10000; balance = myBalance; } // //*Two constructors // //*1)Takes an initial Balance // public BankAccount(String inputName, int inputID, double initialBalance) // { // name = inputName; // ID = inputID; // balance = initialBalance; // // //System.out.println("Name: " // //+ inputName); // //System.out.println("The Intial balance is: " // //+ inputID); // //System.out.println("The Intial balance is: "
  • 4. // //+ initialBalance); // } // // //*2)Opens a new account with no money // // public BankAccount() // // { // // balance = 0.00; // // } //A Deposit Method public static void deposit() { Scanner scan = new Scanner(System.in); System.out.printf("How much would you like to deposit? " + "Enter amount here: $"); double depositAmount = scan.nextDouble(); while(depositAmount <= 0.00) { System.out.println("Invalid deposit amount!"); System.out.printf("How much would you like to deposit? " + "Enter amount here: $"); depositAmount = scan.nextDouble(); } balance += depositAmount; System.out.println("The amount you deposited: $" + depositAmount + ". Your current balance: $"+ balance ); } //A Withdrawal Method public static void withdraw() { Scanner scan = new Scanner(System.in); System.out.printf("How much would you like to withdraw? " + "Enter amount here: $"); double withdrawAmount = scan.nextDouble();
  • 5. while(withdrawAmount <= 0.00) { System.out.println("Invalid withdrawal amount! " + "How much would you like to withdraw? " + "Enter amount here: $"); withdrawAmount = scan.nextDouble(); } while(withdrawAmount > balance) { System.out.println("The balance you want to withdraw " + "is less than what you currently have in " + "this account! How much would you like to " + "withdraw?" + "Enter amount here: $"); withdrawAmount = scan.nextDouble(); } balance -= withdrawAmount; System.out.println("The amount you withdrew: $"+ withdrawAmount + ". Your current balance: $" + balance ); } //Interest Rate public static void addInterestRate() { Scanner scan = new Scanner(System.in); System.out.println("How much would you like to adjust " + "the % interest rate by? Enter % amount here: "); double updateInterestRate = scan.nextDouble(); interestRate += updateInterestRate; balance += (balance * (interestRate / 100)); System.out.println("Current balance is now: $" + balance + " " + "With " + interestRate + "%"); } //A toString Method // public String toString() // {
  • 6. // BankAccount bankObject = new BankAccount(name, ID, interestRate, balance); // System.out.printf("Name: ", bankObject.getName()); // System.out.printf("ID: ", bankObject.getID()); // System.out.printf("Interest Rate: ", bankObject.getInterestRate() + "%"); // System.out.printf("Balance: %", bankObject.getBalance()); // // // return "account"; // } //Driver Program public static void main(String[] args) { //newAccount(); //myAccount(); //deposit(); //withdraw(); //addInterestRate(); String name = "Jonathan"; //any value int ID = 22; //any value double interestRate = 10.2; //any value double balance = 100000.0 //any value BankAccount bankObject = new BankAccount(name, ID, interestRate, balance); System.out.println("Name: " + bankObject.getName()); System.out.println("ID: " + bankObject.getID()); System.out.println("Interest Rate: " + bankObject.getInterestRate() + "%"); System.out.println("Balance: $" + bankObject.getBalance()); } } Solution You are not setting any values for those variables(name, ID, interestRate, balance) when you create the object. Hence, they are instantiated to 0 or null based on the type. Add this to the main method: String name = "Jonathan"; //any value
  • 7. int ID = 22; //any value double interestRate = 10.2; //any value double balance = 100000.0 //any value Hence, your final program should look like this: import java.util.Scanner; public class BankAccount { public BankAccount() { setName(""); setID(0); setBalance(0); setInterestRate(0); } public BankAccount(String name, int ID, double balance, double interestRate) { setName(name); setID(ID); setBalance(balance); setInterestRate(interestRate); } //name private static String name; public void setName (String Name) { this.name = name; } public String getName() { return name; } //ID private static int ID; public void setID (int ID) { this.ID = ID;
  • 8. } public int getID() { return ID; } //balance private static double balance; public void setBalance (double balance) { this.balance = balance; } public double getBalance() { return balance; } //interest rate static double interestRate; public void setInterestRate (double interestrate) { this.interestRate = interestRate; } public double getInterestRate() { return interestRate; } //new account public static void newAccount() { Scanner scan = new Scanner(System.in); System.out.println("Hello new bank user! " + "Welcome to the Bank of Jonathan!"); //Have user input their name System.out.print("Please enter your name: "); name = scan.nextLine(); //An account ID (stored as text) System.out.print("Please enter your Bank ID: ");
  • 9. ID = scan.nextInt(); } //my account public static void myAccount() { Scanner scan = new Scanner(System.in); System.out.println("Welcome to the Bank of Jonathan!"); //Have user input their name System.out.print("Please enter your name: "); name = scan.nextLine(); //An account ID (stored as text) System.out.print("Please enter your Bank ID: "); ID = scan.nextInt(); double myBalance = 10000; balance = myBalance; } // //*Two constructors // //*1)Takes an initial Balance // public BankAccount(String inputName, int inputID, double initialBalance) // { // name = inputName; // ID = inputID; // balance = initialBalance; // // //System.out.println("Name: " // //+ inputName); // //System.out.println("The Intial balance is: " // //+ inputID); // //System.out.println("The Intial balance is: " // //+ initialBalance); // } // // //*2)Opens a new account with no money // // public BankAccount()
  • 10. // // { // // balance = 0.00; // // } //A Deposit Method public static void deposit() { Scanner scan = new Scanner(System.in); System.out.printf("How much would you like to deposit? " + "Enter amount here: $"); double depositAmount = scan.nextDouble(); while(depositAmount <= 0.00) { System.out.println("Invalid deposit amount!"); System.out.printf("How much would you like to deposit? " + "Enter amount here: $"); depositAmount = scan.nextDouble(); } balance += depositAmount; System.out.println("The amount you deposited: $" + depositAmount + ". Your current balance: $"+ balance ); } //A Withdrawal Method public static void withdraw() { Scanner scan = new Scanner(System.in); System.out.printf("How much would you like to withdraw? " + "Enter amount here: $"); double withdrawAmount = scan.nextDouble(); while(withdrawAmount <= 0.00) { System.out.println("Invalid withdrawal amount! " + "How much would you like to withdraw? " + "Enter amount here: $");
  • 11. withdrawAmount = scan.nextDouble(); } while(withdrawAmount > balance) { System.out.println("The balance you want to withdraw " + "is less than what you currently have in " + "this account! How much would you like to " + "withdraw?" + "Enter amount here: $"); withdrawAmount = scan.nextDouble(); } balance -= withdrawAmount; System.out.println("The amount you withdrew: $"+ withdrawAmount + ". Your current balance: $" + balance ); } //Interest Rate public static void addInterestRate() { Scanner scan = new Scanner(System.in); System.out.println("How much would you like to adjust " + "the % interest rate by? Enter % amount here: "); double updateInterestRate = scan.nextDouble(); interestRate += updateInterestRate; balance += (balance * (interestRate / 100)); System.out.println("Current balance is now: $" + balance + " " + "With " + interestRate + "%"); } //A toString Method // public String toString() // { // BankAccount bankObject = new BankAccount(name, ID, interestRate, balance); // System.out.printf("Name: ", bankObject.getName()); // System.out.printf("ID: ", bankObject.getID()); // System.out.printf("Interest Rate: ", bankObject.getInterestRate() + "%"); // System.out.printf("Balance: %", bankObject.getBalance());
  • 12. // // // return "account"; // } //Driver Program public static void main(String[] args) { //newAccount(); //myAccount(); //deposit(); //withdraw(); //addInterestRate(); String name = "Jonathan"; //any value int ID = 22; //any value double interestRate = 10.2; //any value double balance = 100000.0 //any value BankAccount bankObject = new BankAccount(name, ID, interestRate, balance); System.out.println("Name: " + bankObject.getName()); System.out.println("ID: " + bankObject.getID()); System.out.println("Interest Rate: " + bankObject.getInterestRate() + "%"); System.out.println("Balance: $" + bankObject.getBalance()); } }