SlideShare a Scribd company logo
import java.util.Scanner;
import java.text.DecimalFormat;
import java.io.*;
public class SavingAccount //MUST match the file name!
{
public static void main(String[] args)throws IOException
{
//Create a decimal format for displaying dollars
DecimalFormat dollar = new DecimalFormat("#,###.##");
//Constants
double depositSum = 0.0;
double withdrawalSum = 0.0;
double earnedInt = 0.0;
double startBalance = 500; //Starting balance
// Executables
System.out.println("This program solves Programming Challenge 6.11");
System.out.println();
//Create Scanner object for keyboard input.
Scanner keyboard = new Scanner(System.in);
//Get interest rate
System.out.print("Enter the annual interest: ");
double testInterest = keyboard.nextDouble();
//Create an object that accept the starting balance and annual interest
SavingAccount1 account = new SavingAccount1(startBalance, testInterest);
//Open Deposit file.
File file = new File ("BankDeposits.txt");
Scanner inputFile = new Scanner(file);
//Read line in file
while (inputFile.hasNext());
{
//Read numbers
double num = inputFile.nextDouble();
//Add the numbers
depositSum += num;
}
//Deposit the file input.
account.deposit(depositSum);
//Close the file
inputFile.close();
//Open Withdrawal file
File file2 = new File("BankWithdrawal.txt");
Scanner inputFile2 = new Scanner(file2);
//Read lines in file
while (inputFile2.hasNext());
{
//Read numbers
double num2 = inputFile2.nextDouble();
//Add the numbers
withdrawalSum += num2;
}
//Withdrawal the file input from account.
account.withdraw(withdrawalSum);
//Close the file
inputFile2.close();
//Add the monthly interest
account.addInt();
//Get amount of interest earned.
earnedInt += account.getInterest();
//Display the data
System.out.println("Account balance $" + dollar.format(account.getBalance()));
System.out.println("Total interest earned $" + dollar.format(account.getInterest()));
}
}//end class
public class SavingAccount1 //MUST match the file name!
{
public static void main(String[] args)
{
System.out.println("This program solves Programming Challenge 6.10");
System.out.println();
}
//Fields
private double balance; //Account balance
private double annualInterest; //annual interest
private double monthInt; //monthly interest
private double earnedInt; //earned interest
double totalWithdraw;
double totalDeposit;
/**
018
This constructor sets the starting balance
019
and the annual interest at 0.0.
020
*/
public void Ward_Tassinda_SavingAccount1()
{
balance = 0.0;
annualInterest = 0.0;
}
/**
029
This constructor set the starting balance and the annual interest rate
030
to the value passed as an argument.
031
@param startBalance The starting balance.
032
*/
public void Ward_Tassinda_SavingAccount1(double startBalance, double interestRate)
{
balance = startBalance;
annualInterest = interestRate;
}
/**
041
This constructor sets the starting balance to
042
the value in the String argument.
043
@param str The starting balance, as a String.
044
*/
public void Ward_Tassinda_SavingAccount1(String str)
{
balance = Double.parseDouble(str);
}
/**
052
The deposit method makes a depositinto
053
the account.
054
@param amount The amount to add to the balance field.
055
*/
public void deposit(double amount)
{
balance += amount;
totalDeposit += amount;
}
/**
064
The deposit method makes a deposit into the account.
065
@param str The amount to add to the balance field,
066
as a String.
067
*/
public void deposit (String str)
{
balance += Double.parseDouble(str);
}
/**
075
The withdraw method withdraws an amount from
076
the account.
077
@param amount The amount to subtract from the
078
balance field.
079
*/
public void withdraw (double amount)
{
balance -= amount;
totalWithdraw += amount;
}
/**
088
The withdraw method withdraws an amount from
089
the account.
090
@param str The amount to subtract from the
091
balance field, as a String.
092
*/
public void withdraw (String str)
{
balance -= Double.parseDouble(str);
}
/**
100
The addInt method calculates the montly
101
interest in the account.
102
@param monthlyInterest The annual interest
103
divided by 12.
104
*/
public void addInt()
{
monthInt = ((annualInterest/100) / 12);
balance += earnedInt;
earnedInt += (monthInt * balance);
}
/**
114
The setBalance method sets the account balance.
115
@param b The value to store in the balance field.
116
*/
public void setBalance(double b)
{
balance = b;
}
/**
124
The setBalance method sets the account balance.
125
@param str The value, as a String, to store in
126
the balance field.
127
*/
public void setBalance(String str)
{
balance = Double.parseDouble(str);
}
/**
135
The setInterest method sets the account's
136
monthly interest.
137
@param i The value to store in the interest field.
138
*/
public void setInterest (double i)
{
earnedInt = i;
}
public void setInterest (String str)
{
earnedInt = Double.parseDouble(str);
}
/**
151
The getBalance method returns the
152
account balance.
153
@return The value in the balance field.
154
*/
public double getBalance()
{
return balance;
}
/**
162
The getInterest method returns the
163
earned interest.
164
@return The value in the interest field.
165
*/
public double getInterest()
{
return earnedInt;
}
}//end class
Solution
import java.util.Scanner;
import java.text.DecimalFormat;
import java.io.*;
public class SavingAccount //MUST match the file name!
{
public static void main(String[] args)throws IOException
{
//Create a decimal format for displaying dollars
DecimalFormat dollar = new DecimalFormat("#,###.##");
//Constants
double depositSum = 0.0;
double withdrawalSum = 0.0;
double earnedInt = 0.0;
double startBalance = 500; //Starting balance
// Executables
System.out.println("This program solves Programming Challenge 6.11");
System.out.println();
//Create Scanner object for keyboard input.
Scanner keyboard = new Scanner(System.in);
//Get interest rate
System.out.print("Enter the annual interest: ");
double testInterest = keyboard.nextDouble();
//Create an object that accept the starting balance and annual interest
SavingAccount1 account = new SavingAccount1(startBalance, testInterest);
//Open Deposit file.
File file = new File ("BankDeposits.txt");
Scanner inputFile = new Scanner(file);
//Read line in file
while (inputFile.hasNext());
{
//Read numbers
double num = inputFile.nextDouble();
//Add the numbers
depositSum += num;
}
//Deposit the file input.
account.deposit(depositSum);
//Close the file
inputFile.close();
//Open Withdrawal file
File file2 = new File("BankWithdrawal.txt");
Scanner inputFile2 = new Scanner(file2);
//Read lines in file
while (inputFile2.hasNext());
{
//Read numbers
double num2 = inputFile2.nextDouble();
//Add the numbers
withdrawalSum += num2;
}
//Withdrawal the file input from account.
account.withdraw(withdrawalSum);
//Close the file
inputFile2.close();
//Add the monthly interest
account.addInt();
//Get amount of interest earned.
earnedInt += account.getInterest();
//Display the data
System.out.println("Account balance $" + dollar.format(account.getBalance()));
System.out.println("Total interest earned $" + dollar.format(account.getInterest()));
}
}//end class
public class SavingAccount1 //MUST match the file name!
{
public static void main(String[] args)
{
System.out.println("This program solves Programming Challenge 6.10");
System.out.println();
}
//Fields
private double balance; //Account balance
private double annualInterest; //annual interest
private double monthInt; //monthly interest
private double earnedInt; //earned interest
double totalWithdraw;
double totalDeposit;
/**
018
This constructor sets the starting balance
019
and the annual interest at 0.0.
020
*/
public void Ward_Tassinda_SavingAccount1()
{
balance = 0.0;
annualInterest = 0.0;
}
/**
029
This constructor set the starting balance and the annual interest rate
030
to the value passed as an argument.
031
@param startBalance The starting balance.
032
*/
public void Ward_Tassinda_SavingAccount1(double startBalance, double interestRate)
{
balance = startBalance;
annualInterest = interestRate;
}
/**
041
This constructor sets the starting balance to
042
the value in the String argument.
043
@param str The starting balance, as a String.
044
*/
public void Ward_Tassinda_SavingAccount1(String str)
{
balance = Double.parseDouble(str);
}
/**
052
The deposit method makes a depositinto
053
the account.
054
@param amount The amount to add to the balance field.
055
*/
public void deposit(double amount)
{
balance += amount;
totalDeposit += amount;
}
/**
064
The deposit method makes a deposit into the account.
065
@param str The amount to add to the balance field,
066
as a String.
067
*/
public void deposit (String str)
{
balance += Double.parseDouble(str);
}
/**
075
The withdraw method withdraws an amount from
076
the account.
077
@param amount The amount to subtract from the
078
balance field.
079
*/
public void withdraw (double amount)
{
balance -= amount;
totalWithdraw += amount;
}
/**
088
The withdraw method withdraws an amount from
089
the account.
090
@param str The amount to subtract from the
091
balance field, as a String.
092
*/
public void withdraw (String str)
{
balance -= Double.parseDouble(str);
}
/**
100
The addInt method calculates the montly
101
interest in the account.
102
@param monthlyInterest The annual interest
103
divided by 12.
104
*/
public void addInt()
{
monthInt = ((annualInterest/100) / 12);
balance += earnedInt;
earnedInt += (monthInt * balance);
}
/**
114
The setBalance method sets the account balance.
115
@param b The value to store in the balance field.
116
*/
public void setBalance(double b)
{
balance = b;
}
/**
124
The setBalance method sets the account balance.
125
@param str The value, as a String, to store in
126
the balance field.
127
*/
public void setBalance(String str)
{
balance = Double.parseDouble(str);
}
/**
135
The setInterest method sets the account's
136
monthly interest.
137
@param i The value to store in the interest field.
138
*/
public void setInterest (double i)
{
earnedInt = i;
}
public void setInterest (String str)
{
earnedInt = Double.parseDouble(str);
}
/**
151
The getBalance method returns the
152
account balance.
153
@return The value in the balance field.
154
*/
public double getBalance()
{
return balance;
}
/**
162
The getInterest method returns the
163
earned interest.
164
@return The value in the interest field.
165
*/
public double getInterest()
{
return earnedInt;
}
}//end class

More Related Content

Similar to import java.util.Scanner;import java.text.DecimalFormat;import j.pdf

Modify the bouncing ball example demonstrated/tutorialoutlet
Modify the bouncing ball example demonstrated/tutorialoutletModify the bouncing ball example demonstrated/tutorialoutlet
Modify the bouncing ball example demonstrated/tutorialoutlet
Cleasbyz
 
Change to oop formatimport java.util.Scanner;import java.io.;.pdf
Change to oop formatimport java.util.Scanner;import java.io.;.pdfChange to oop formatimport java.util.Scanner;import java.io.;.pdf
Change to oop formatimport java.util.Scanner;import java.io.;.pdf
MAYANKBANSAL1981
 
JavaExamples
JavaExamplesJavaExamples
JavaExamples
Suman Astani
 
You are not setting any values for those variables(name, ID, interes.pdf
You are not setting any values for those variables(name, ID, interes.pdfYou are not setting any values for those variables(name, ID, interes.pdf
You are not setting any values for those variables(name, ID, interes.pdf
deepakangel
 
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxPROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
amrit47
 
SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdf
SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdfSummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdf
SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdf
ARORACOCKERY2111
 
Integration Project Inspection 3
Integration Project Inspection 3Integration Project Inspection 3
Integration Project Inspection 3Dillon Lee
 
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
 
I need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdfI need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdf
pnaran46
 
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
 
07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt
Ajenkris Kungkung
 
C# Programming. Using methods to call results to display. The code i.pdf
C# Programming. Using methods to call results to display. The code i.pdfC# Programming. Using methods to call results to display. The code i.pdf
C# Programming. Using methods to call results to display. The code i.pdf
fatoryoutlets
 
My code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdfMy code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdf
adianantsolutions
 

Similar to import java.util.Scanner;import java.text.DecimalFormat;import j.pdf (16)

CP 04.pptx
CP 04.pptxCP 04.pptx
CP 04.pptx
 
Modify the bouncing ball example demonstrated/tutorialoutlet
Modify the bouncing ball example demonstrated/tutorialoutletModify the bouncing ball example demonstrated/tutorialoutlet
Modify the bouncing ball example demonstrated/tutorialoutlet
 
Change to oop formatimport java.util.Scanner;import java.io.;.pdf
Change to oop formatimport java.util.Scanner;import java.io.;.pdfChange to oop formatimport java.util.Scanner;import java.io.;.pdf
Change to oop formatimport java.util.Scanner;import java.io.;.pdf
 
JavaExamples
JavaExamplesJavaExamples
JavaExamples
 
You are not setting any values for those variables(name, ID, interes.pdf
You are not setting any values for those variables(name, ID, interes.pdfYou are not setting any values for those variables(name, ID, interes.pdf
You are not setting any values for those variables(name, ID, interes.pdf
 
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxPROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
 
SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdf
SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdfSummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdf
SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdf
 
Integration Project Inspection 3
Integration Project Inspection 3Integration Project Inspection 3
Integration Project Inspection 3
 
Day 1
Day 1Day 1
Day 1
 
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
 
I need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdfI need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.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
 
Oop Presentation
Oop PresentationOop Presentation
Oop Presentation
 
07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt
 
C# Programming. Using methods to call results to display. The code i.pdf
C# Programming. Using methods to call results to display. The code i.pdfC# Programming. Using methods to call results to display. The code i.pdf
C# Programming. Using methods to call results to display. The code i.pdf
 
My code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdfMy code is below How do I write this code without usin.pdf
My code is below How do I write this code without usin.pdf
 

More from KUNALHARCHANDANI1

The metal will undergo oxidation forming metal ion and releasing .pdf
 The metal will undergo oxidation forming metal ion and releasing .pdf The metal will undergo oxidation forming metal ion and releasing .pdf
The metal will undergo oxidation forming metal ion and releasing .pdf
KUNALHARCHANDANI1
 
Static Keyword Static is a keyword in C++ used to give special chara.pdf
  Static Keyword Static is a keyword in C++ used to give special chara.pdf  Static Keyword Static is a keyword in C++ used to give special chara.pdf
Static Keyword Static is a keyword in C++ used to give special chara.pdf
KUNALHARCHANDANI1
 
Sr2+ is most likely to substitute for Ca2+ becaus.pdf
                     Sr2+ is most likely to substitute for Ca2+ becaus.pdf                     Sr2+ is most likely to substitute for Ca2+ becaus.pdf
Sr2+ is most likely to substitute for Ca2+ becaus.pdf
KUNALHARCHANDANI1
 
may be that peak id due to presence of alkyl gro.pdf
                     may be that peak id due to presence of  alkyl gro.pdf                     may be that peak id due to presence of  alkyl gro.pdf
may be that peak id due to presence of alkyl gro.pdf
KUNALHARCHANDANI1
 
There should only have one singlet resonance for .pdf
                     There should only have one singlet resonance for .pdf                     There should only have one singlet resonance for .pdf
There should only have one singlet resonance for .pdf
KUNALHARCHANDANI1
 
the link is not working can u pls write questions.pdf
                     the link is not working can u pls write questions.pdf                     the link is not working can u pls write questions.pdf
the link is not working can u pls write questions.pdf
KUNALHARCHANDANI1
 
The one have higher value of E(cell) is acting as.pdf
                     The one have higher value of E(cell) is acting as.pdf                     The one have higher value of E(cell) is acting as.pdf
The one have higher value of E(cell) is acting as.pdf
KUNALHARCHANDANI1
 
Nicotine has a molecular formula of C10H14N2 .pdf
                     Nicotine has a molecular formula of C10H14N2     .pdf                     Nicotine has a molecular formula of C10H14N2     .pdf
Nicotine has a molecular formula of C10H14N2 .pdf
KUNALHARCHANDANI1
 
i have it .pdf
                     i have it                                      .pdf                     i have it                                      .pdf
i have it .pdf
KUNALHARCHANDANI1
 
HClO4 in aqueous medium ionizes as Hydrogen(+1)ca.pdf
                     HClO4 in aqueous medium ionizes as Hydrogen(+1)ca.pdf                     HClO4 in aqueous medium ionizes as Hydrogen(+1)ca.pdf
HClO4 in aqueous medium ionizes as Hydrogen(+1)ca.pdf
KUNALHARCHANDANI1
 
Which of the following would be a description of a system unitA c.pdf
Which of the following would be a description of a system unitA c.pdfWhich of the following would be a description of a system unitA c.pdf
Which of the following would be a description of a system unitA c.pdf
KUNALHARCHANDANI1
 
Water is a polar inorganic solvent. Benzene is a nonpolar organic so.pdf
Water is a polar inorganic solvent. Benzene is a nonpolar organic so.pdfWater is a polar inorganic solvent. Benzene is a nonpolar organic so.pdf
Water is a polar inorganic solvent. Benzene is a nonpolar organic so.pdf
KUNALHARCHANDANI1
 
viruses which have single strande DNA in their genome come under cat.pdf
viruses which have single strande DNA in their genome come under cat.pdfviruses which have single strande DNA in their genome come under cat.pdf
viruses which have single strande DNA in their genome come under cat.pdf
KUNALHARCHANDANI1
 
This word problem is about a triangle whose perimeter is 47 miles. S.pdf
This word problem is about a triangle whose perimeter is 47 miles. S.pdfThis word problem is about a triangle whose perimeter is 47 miles. S.pdf
This word problem is about a triangle whose perimeter is 47 miles. S.pdf
KUNALHARCHANDANI1
 
CH4 + 2O2 -- CO2 + 2H2O note CH4 combustion is.pdf
                     CH4 + 2O2 -- CO2 + 2H2O  note CH4 combustion is.pdf                     CH4 + 2O2 -- CO2 + 2H2O  note CH4 combustion is.pdf
CH4 + 2O2 -- CO2 + 2H2O note CH4 combustion is.pdf
KUNALHARCHANDANI1
 
SbAspnSolutionSbAspn.pdf
SbAspnSolutionSbAspn.pdfSbAspnSolutionSbAspn.pdf
SbAspnSolutionSbAspn.pdf
KUNALHARCHANDANI1
 
Carbon 2 is where D and L differ for all sugars. .pdf
                     Carbon 2 is where D and L differ for all sugars. .pdf                     Carbon 2 is where D and L differ for all sugars. .pdf
Carbon 2 is where D and L differ for all sugars. .pdf
KUNALHARCHANDANI1
 
Program to print the Diamond Shape -#include stdio.h int ma.pdf
Program to print the Diamond Shape -#include stdio.h int ma.pdfProgram to print the Diamond Shape -#include stdio.h int ma.pdf
Program to print the Diamond Shape -#include stdio.h int ma.pdf
KUNALHARCHANDANI1
 
Part D option 4 is answerUnless untill they are exposed by some me.pdf
Part D option 4 is answerUnless untill they are exposed by some me.pdfPart D option 4 is answerUnless untill they are exposed by some me.pdf
Part D option 4 is answerUnless untill they are exposed by some me.pdf
KUNALHARCHANDANI1
 
Isomers which have their atoms connected in the same sequence but di.pdf
Isomers which have their atoms connected in the same sequence but di.pdfIsomers which have their atoms connected in the same sequence but di.pdf
Isomers which have their atoms connected in the same sequence but di.pdf
KUNALHARCHANDANI1
 

More from KUNALHARCHANDANI1 (20)

The metal will undergo oxidation forming metal ion and releasing .pdf
 The metal will undergo oxidation forming metal ion and releasing .pdf The metal will undergo oxidation forming metal ion and releasing .pdf
The metal will undergo oxidation forming metal ion and releasing .pdf
 
Static Keyword Static is a keyword in C++ used to give special chara.pdf
  Static Keyword Static is a keyword in C++ used to give special chara.pdf  Static Keyword Static is a keyword in C++ used to give special chara.pdf
Static Keyword Static is a keyword in C++ used to give special chara.pdf
 
Sr2+ is most likely to substitute for Ca2+ becaus.pdf
                     Sr2+ is most likely to substitute for Ca2+ becaus.pdf                     Sr2+ is most likely to substitute for Ca2+ becaus.pdf
Sr2+ is most likely to substitute for Ca2+ becaus.pdf
 
may be that peak id due to presence of alkyl gro.pdf
                     may be that peak id due to presence of  alkyl gro.pdf                     may be that peak id due to presence of  alkyl gro.pdf
may be that peak id due to presence of alkyl gro.pdf
 
There should only have one singlet resonance for .pdf
                     There should only have one singlet resonance for .pdf                     There should only have one singlet resonance for .pdf
There should only have one singlet resonance for .pdf
 
the link is not working can u pls write questions.pdf
                     the link is not working can u pls write questions.pdf                     the link is not working can u pls write questions.pdf
the link is not working can u pls write questions.pdf
 
The one have higher value of E(cell) is acting as.pdf
                     The one have higher value of E(cell) is acting as.pdf                     The one have higher value of E(cell) is acting as.pdf
The one have higher value of E(cell) is acting as.pdf
 
Nicotine has a molecular formula of C10H14N2 .pdf
                     Nicotine has a molecular formula of C10H14N2     .pdf                     Nicotine has a molecular formula of C10H14N2     .pdf
Nicotine has a molecular formula of C10H14N2 .pdf
 
i have it .pdf
                     i have it                                      .pdf                     i have it                                      .pdf
i have it .pdf
 
HClO4 in aqueous medium ionizes as Hydrogen(+1)ca.pdf
                     HClO4 in aqueous medium ionizes as Hydrogen(+1)ca.pdf                     HClO4 in aqueous medium ionizes as Hydrogen(+1)ca.pdf
HClO4 in aqueous medium ionizes as Hydrogen(+1)ca.pdf
 
Which of the following would be a description of a system unitA c.pdf
Which of the following would be a description of a system unitA c.pdfWhich of the following would be a description of a system unitA c.pdf
Which of the following would be a description of a system unitA c.pdf
 
Water is a polar inorganic solvent. Benzene is a nonpolar organic so.pdf
Water is a polar inorganic solvent. Benzene is a nonpolar organic so.pdfWater is a polar inorganic solvent. Benzene is a nonpolar organic so.pdf
Water is a polar inorganic solvent. Benzene is a nonpolar organic so.pdf
 
viruses which have single strande DNA in their genome come under cat.pdf
viruses which have single strande DNA in their genome come under cat.pdfviruses which have single strande DNA in their genome come under cat.pdf
viruses which have single strande DNA in their genome come under cat.pdf
 
This word problem is about a triangle whose perimeter is 47 miles. S.pdf
This word problem is about a triangle whose perimeter is 47 miles. S.pdfThis word problem is about a triangle whose perimeter is 47 miles. S.pdf
This word problem is about a triangle whose perimeter is 47 miles. S.pdf
 
CH4 + 2O2 -- CO2 + 2H2O note CH4 combustion is.pdf
                     CH4 + 2O2 -- CO2 + 2H2O  note CH4 combustion is.pdf                     CH4 + 2O2 -- CO2 + 2H2O  note CH4 combustion is.pdf
CH4 + 2O2 -- CO2 + 2H2O note CH4 combustion is.pdf
 
SbAspnSolutionSbAspn.pdf
SbAspnSolutionSbAspn.pdfSbAspnSolutionSbAspn.pdf
SbAspnSolutionSbAspn.pdf
 
Carbon 2 is where D and L differ for all sugars. .pdf
                     Carbon 2 is where D and L differ for all sugars. .pdf                     Carbon 2 is where D and L differ for all sugars. .pdf
Carbon 2 is where D and L differ for all sugars. .pdf
 
Program to print the Diamond Shape -#include stdio.h int ma.pdf
Program to print the Diamond Shape -#include stdio.h int ma.pdfProgram to print the Diamond Shape -#include stdio.h int ma.pdf
Program to print the Diamond Shape -#include stdio.h int ma.pdf
 
Part D option 4 is answerUnless untill they are exposed by some me.pdf
Part D option 4 is answerUnless untill they are exposed by some me.pdfPart D option 4 is answerUnless untill they are exposed by some me.pdf
Part D option 4 is answerUnless untill they are exposed by some me.pdf
 
Isomers which have their atoms connected in the same sequence but di.pdf
Isomers which have their atoms connected in the same sequence but di.pdfIsomers which have their atoms connected in the same sequence but di.pdf
Isomers which have their atoms connected in the same sequence but di.pdf
 

Recently uploaded

STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
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
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
gb193092
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 

Recently uploaded (20)

STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
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
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 

import java.util.Scanner;import java.text.DecimalFormat;import j.pdf

  • 1. import java.util.Scanner; import java.text.DecimalFormat; import java.io.*; public class SavingAccount //MUST match the file name! { public static void main(String[] args)throws IOException { //Create a decimal format for displaying dollars DecimalFormat dollar = new DecimalFormat("#,###.##"); //Constants double depositSum = 0.0; double withdrawalSum = 0.0; double earnedInt = 0.0; double startBalance = 500; //Starting balance // Executables System.out.println("This program solves Programming Challenge 6.11"); System.out.println(); //Create Scanner object for keyboard input. Scanner keyboard = new Scanner(System.in); //Get interest rate System.out.print("Enter the annual interest: "); double testInterest = keyboard.nextDouble(); //Create an object that accept the starting balance and annual interest SavingAccount1 account = new SavingAccount1(startBalance, testInterest); //Open Deposit file. File file = new File ("BankDeposits.txt"); Scanner inputFile = new Scanner(file); //Read line in file while (inputFile.hasNext()); { //Read numbers double num = inputFile.nextDouble(); //Add the numbers depositSum += num; }
  • 2. //Deposit the file input. account.deposit(depositSum); //Close the file inputFile.close(); //Open Withdrawal file File file2 = new File("BankWithdrawal.txt"); Scanner inputFile2 = new Scanner(file2); //Read lines in file while (inputFile2.hasNext()); { //Read numbers double num2 = inputFile2.nextDouble(); //Add the numbers withdrawalSum += num2; } //Withdrawal the file input from account. account.withdraw(withdrawalSum); //Close the file inputFile2.close(); //Add the monthly interest account.addInt(); //Get amount of interest earned. earnedInt += account.getInterest(); //Display the data System.out.println("Account balance $" + dollar.format(account.getBalance())); System.out.println("Total interest earned $" + dollar.format(account.getInterest())); } }//end class public class SavingAccount1 //MUST match the file name! { public static void main(String[] args) { System.out.println("This program solves Programming Challenge 6.10"); System.out.println(); } //Fields
  • 3. private double balance; //Account balance private double annualInterest; //annual interest private double monthInt; //monthly interest private double earnedInt; //earned interest double totalWithdraw; double totalDeposit; /** 018 This constructor sets the starting balance 019 and the annual interest at 0.0. 020 */ public void Ward_Tassinda_SavingAccount1() { balance = 0.0; annualInterest = 0.0; } /** 029 This constructor set the starting balance and the annual interest rate 030 to the value passed as an argument. 031 @param startBalance The starting balance. 032 */ public void Ward_Tassinda_SavingAccount1(double startBalance, double interestRate) { balance = startBalance; annualInterest = interestRate; } /** 041 This constructor sets the starting balance to 042
  • 4. the value in the String argument. 043 @param str The starting balance, as a String. 044 */ public void Ward_Tassinda_SavingAccount1(String str) { balance = Double.parseDouble(str); } /** 052 The deposit method makes a depositinto 053 the account. 054 @param amount The amount to add to the balance field. 055 */ public void deposit(double amount) { balance += amount; totalDeposit += amount; } /** 064 The deposit method makes a deposit into the account. 065 @param str The amount to add to the balance field, 066 as a String. 067 */ public void deposit (String str) { balance += Double.parseDouble(str);
  • 5. } /** 075 The withdraw method withdraws an amount from 076 the account. 077 @param amount The amount to subtract from the 078 balance field. 079 */ public void withdraw (double amount) { balance -= amount; totalWithdraw += amount; } /** 088 The withdraw method withdraws an amount from 089 the account. 090 @param str The amount to subtract from the 091 balance field, as a String. 092 */ public void withdraw (String str) { balance -= Double.parseDouble(str); } /** 100 The addInt method calculates the montly 101
  • 6. interest in the account. 102 @param monthlyInterest The annual interest 103 divided by 12. 104 */ public void addInt() { monthInt = ((annualInterest/100) / 12); balance += earnedInt; earnedInt += (monthInt * balance); } /** 114 The setBalance method sets the account balance. 115 @param b The value to store in the balance field. 116 */ public void setBalance(double b) { balance = b; } /** 124 The setBalance method sets the account balance. 125 @param str The value, as a String, to store in 126 the balance field. 127 */ public void setBalance(String str) { balance = Double.parseDouble(str);
  • 7. } /** 135 The setInterest method sets the account's 136 monthly interest. 137 @param i The value to store in the interest field. 138 */ public void setInterest (double i) { earnedInt = i; } public void setInterest (String str) { earnedInt = Double.parseDouble(str); } /** 151 The getBalance method returns the 152 account balance. 153 @return The value in the balance field. 154 */ public double getBalance() { return balance; } /** 162 The getInterest method returns the 163 earned interest.
  • 8. 164 @return The value in the interest field. 165 */ public double getInterest() { return earnedInt; } }//end class Solution import java.util.Scanner; import java.text.DecimalFormat; import java.io.*; public class SavingAccount //MUST match the file name! { public static void main(String[] args)throws IOException { //Create a decimal format for displaying dollars DecimalFormat dollar = new DecimalFormat("#,###.##"); //Constants double depositSum = 0.0; double withdrawalSum = 0.0; double earnedInt = 0.0; double startBalance = 500; //Starting balance // Executables System.out.println("This program solves Programming Challenge 6.11"); System.out.println(); //Create Scanner object for keyboard input. Scanner keyboard = new Scanner(System.in); //Get interest rate System.out.print("Enter the annual interest: "); double testInterest = keyboard.nextDouble(); //Create an object that accept the starting balance and annual interest SavingAccount1 account = new SavingAccount1(startBalance, testInterest);
  • 9. //Open Deposit file. File file = new File ("BankDeposits.txt"); Scanner inputFile = new Scanner(file); //Read line in file while (inputFile.hasNext()); { //Read numbers double num = inputFile.nextDouble(); //Add the numbers depositSum += num; } //Deposit the file input. account.deposit(depositSum); //Close the file inputFile.close(); //Open Withdrawal file File file2 = new File("BankWithdrawal.txt"); Scanner inputFile2 = new Scanner(file2); //Read lines in file while (inputFile2.hasNext()); { //Read numbers double num2 = inputFile2.nextDouble(); //Add the numbers withdrawalSum += num2; } //Withdrawal the file input from account. account.withdraw(withdrawalSum); //Close the file inputFile2.close(); //Add the monthly interest account.addInt(); //Get amount of interest earned. earnedInt += account.getInterest(); //Display the data System.out.println("Account balance $" + dollar.format(account.getBalance()));
  • 10. System.out.println("Total interest earned $" + dollar.format(account.getInterest())); } }//end class public class SavingAccount1 //MUST match the file name! { public static void main(String[] args) { System.out.println("This program solves Programming Challenge 6.10"); System.out.println(); } //Fields private double balance; //Account balance private double annualInterest; //annual interest private double monthInt; //monthly interest private double earnedInt; //earned interest double totalWithdraw; double totalDeposit; /** 018 This constructor sets the starting balance 019 and the annual interest at 0.0. 020 */ public void Ward_Tassinda_SavingAccount1() { balance = 0.0; annualInterest = 0.0; } /** 029 This constructor set the starting balance and the annual interest rate 030 to the value passed as an argument. 031 @param startBalance The starting balance.
  • 11. 032 */ public void Ward_Tassinda_SavingAccount1(double startBalance, double interestRate) { balance = startBalance; annualInterest = interestRate; } /** 041 This constructor sets the starting balance to 042 the value in the String argument. 043 @param str The starting balance, as a String. 044 */ public void Ward_Tassinda_SavingAccount1(String str) { balance = Double.parseDouble(str); } /** 052 The deposit method makes a depositinto 053 the account. 054 @param amount The amount to add to the balance field. 055 */ public void deposit(double amount) { balance += amount; totalDeposit += amount; } /**
  • 12. 064 The deposit method makes a deposit into the account. 065 @param str The amount to add to the balance field, 066 as a String. 067 */ public void deposit (String str) { balance += Double.parseDouble(str); } /** 075 The withdraw method withdraws an amount from 076 the account. 077 @param amount The amount to subtract from the 078 balance field. 079 */ public void withdraw (double amount) { balance -= amount; totalWithdraw += amount; } /** 088 The withdraw method withdraws an amount from 089 the account. 090 @param str The amount to subtract from the 091
  • 13. balance field, as a String. 092 */ public void withdraw (String str) { balance -= Double.parseDouble(str); } /** 100 The addInt method calculates the montly 101 interest in the account. 102 @param monthlyInterest The annual interest 103 divided by 12. 104 */ public void addInt() { monthInt = ((annualInterest/100) / 12); balance += earnedInt; earnedInt += (monthInt * balance); } /** 114 The setBalance method sets the account balance. 115 @param b The value to store in the balance field. 116 */ public void setBalance(double b) { balance = b; } /**
  • 14. 124 The setBalance method sets the account balance. 125 @param str The value, as a String, to store in 126 the balance field. 127 */ public void setBalance(String str) { balance = Double.parseDouble(str); } /** 135 The setInterest method sets the account's 136 monthly interest. 137 @param i The value to store in the interest field. 138 */ public void setInterest (double i) { earnedInt = i; } public void setInterest (String str) { earnedInt = Double.parseDouble(str); } /** 151 The getBalance method returns the 152 account balance. 153 @return The value in the balance field.
  • 15. 154 */ public double getBalance() { return balance; } /** 162 The getInterest method returns the 163 earned interest. 164 @return The value in the interest field. 165 */ public double getInterest() { return earnedInt; } }//end class