Hi,
I have updated the code as per your requirement. Highlighted the code changes below.
Program2.java
import java.util.Scanner; // Needed for the Scanner class
import java.text.DecimalFormat; // Needed for 2 decimal place amounts
public class Program2
{
public static void main(String[] args)
{
BankAccount account; // To reference a BankAccount object
double balance, // The account\'s starting balance
interestRate, // The annual interest rate
pay, // The user\'s pay
cashNeeded; // The amount of cash to withdraw
// Create a Scanner object for keyboard input.
Scanner keyboard = new Scanner(System.in);
// Create an object for dollars and cents
DecimalFormat formatter = new DecimalFormat (\"#0.00\");
// Get the starting balance.
System.out.print(\"What is your account\'s \" + \"starting balance? \");
balance = keyboard.nextDouble();
// Get the monthly interest rate.
System.out.print(\"What is your an annual interest rate? \");
interestRate = keyboard.nextDouble();
// Create a BankAccount object.
account = new BankAccount(balance, interestRate);
// Get the amount of pay for the month.
System.out.print(\"How much were you paid this month? \");
pay = keyboard.nextDouble();
// Deposit the user\'s pay into the account.
System.out.println(\"We will deposit your pay \" + \"into your account.\");
account.deposit(pay);
System.out.println(\"Your current balance is \" + formatter.format( account.getBalance() ));
// Withdraw some cash from the account.
System.out.print(\"How much would you like \" + \"to withdraw? \");
cashNeeded = keyboard.nextDouble();
account.withdraw(cashNeeded);
// Add the monthly interest to the account.
account.addInterest();
// Display the interest earned and the balance.
System.out.println(\"This month you have earned \" + formatter.format( account.getInterest() ) +
\" in interest.\");
System.out.println(\"Now your balance is \"+ formatter.format( account.getBalance() ) );
}
}
BankAccount.java
public class BankAccount
{
private double balance; // Account balance
private double interestRate; // Interest rate
private double interest; // Interest earned
/**
* The constructor initializes the balance
* and interestRate fields with the values
* passed to startBalance and intRate. The
* interest field is assigned to 0.0.
*/
public BankAccount(double startBalance, double intRate)
{
balance = startBalance;
interestRate = intRate / (12 * 100);
interest = 0.0;
}
/**
* The deposit method adds the parameter
* amount to the balance field.
*/
public void deposit(double amount)
{
balance += amount;
}
/**
* The withdraw method subtracts the
* parameter amount from the balance
* field.
*/
public void withdraw(double amount)
{
balance -= amount;
}
/**
* The addInterest method adds the interest
* for the month to the balance field.
*/
public void addInterest()
{
interest = balance * interestRate;
balance += interest;
}
/**
* The getBalance method returns the
* value in the balance field.
*/
public double getBalance()
{
return balance;
}
/**
* The getIn.
Java programI made this Account.java below. Using the attached cod.pdffathimafancy
Java program
I made this Account.java below. Using the attached code I need help with 10.7 (Game: ATM
machine)
Use the Account class created in Programming Exercise 9.7 to simulate an ATM machine.
Create ten accounts in an array with id 0, 1, . . . , 9, and initial balance $100.
The system prompts the user to enter an id. If the id is entered incorrectly, ask the user to enter a
correct id.
Once an id is accepted, the main menu is displayed as shown in the sample run.
You can enter a choice 1 for viewing the current balance, 2 for withdrawing money, 3 for
depositing money, and 4 for exiting the main menu.
Once you exit, the system will prompt for an id again. Thus, once the system starts, it will not
stop.
*/
import java.util.Date;
public class Account {
/**
* @param args
*/
private int id=0;
private double balance=0;
private double annualIntrestRate=0;
private Date dateCreated;
public Account() {
super();
}
public Account(int id, double balance) {
super();
this.id = id;
this.balance = balance;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public double getAnnualIntrestRate() {
return annualIntrestRate;
}
public void setAnnualIntrestRate(double annualIntrestRate) {
this.annualIntrestRate = annualIntrestRate;
}
public Date getDateCreated() {
return dateCreated;
}
public void setDateCreated(Date dateCreated) {
this.dateCreated = dateCreated;
}
public double getMonthlyInterestRate()
{
return (this.getAnnualIntrestRate()/12);
}
public double getMonthlyInterest()
{
return (getBalance() *getMonthlyInterestRate()/100);
}
public double withDraw(double balance)
{
this.setBalance(this.getBalance()-balance);
return this.getBalance();
}
public double diposite(double balance)
{
this.setBalance(this.getBalance()+balance);
return this.getBalance();
}
public double totalBalance()
{
balance =balance + getMonthlyInterest();
return balance;
}
}
//AccountTest.java
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;
public class AccountTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
Account ac=new Account(1,5000.00);
System.out.println(\"Enter the annual intrest rate\");
double intrestRate=sc.nextDouble();
ac.setAnnualIntrestRate(intrestRate);
Date d=new Date();
Calendar currentDate = Calendar.getInstance();
ac.setDateCreated(currentDate.getTime());
System.out.println(\"Date id \"+ac.getDateCreated());
System.out.println(\"Monthly intrest rate is :\"+ac.getMonthlyInterestRate());
System.out.println(\"Monthly intrest is :\"+ac.getMonthlyInterest());
System.out.println(\"Enter Amount for diposite \");
double dipositeAmount=sc.nextDouble();
System.out.println(\"The amount after diposite is :\"+ac.diposite(dipositeAmount));
System.out.println(\"Enter Amount to withdraw :\");
double withdramount= sc.nextDouble.
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 .
Consider this C++ BankAccount class with the following public member.pdfarchigallery1298
Consider this C++ BankAccount class with the following public member functions.
/* Constructs an object to represent a bank account.
*
* Parameter:
* double initial_balance -- the starting balance of the account
* /
BankAccount(double initial_balance);
/* Adds a certain amount the balance of the account.
*
* Parameter:
* double amount -- the amount to add to the balance
*
* Returns:
* nothing
*/
void deposit(double amount);
/* Subtracts a certain amount from the balance of the account.
*
* Parameter:
* double amount -- the amount to subtract from the balance
*
* Returns:
* nothing
*/
void withdraw(double amount);
/* Gets the balance of the account.
*
* Parameters:
* none
*
* Returns:
* double -- the balance of the account
*/
double get_balance();
(a) Which are the accessor function(s)?
(b) Which are the mutator function(s)?
(c) Create an object to represent a checking account with a starting balance of $1500.
(d) Provide a fragment of C++ code to perform this sequence of actions on the checking
account: deposit $100, print the balance, withdraw $250.
Solution
a) accessors
get_balance()
b) mutators
void deposit(double)
void withdraw(double)
c) BankAccount acc(1500.0);
d) acc.deposit(100.0)
acc.get_balance();
acc.withdraw(250.0).
I need help creating a basic and simple Java program. Here is the ex.pdfrajeshjangid1865
I need help creating a basic and simple Java program. Here is the exercise. I have included my
Account class that is referred to at the bottom, below the exercise.
Use the Account class created in Programming Exercise 9.7 to simulate an ATM machine.
Create ten accounts in an array with id 0, 1, . . . , 9, and initial balance $100. The system prompts
the user to enter an id. If the id is entered incorrectly, ask the user to enter a correct id. Once an
id is accepted, the main menu is displayed as shown in the sample run. You can enter a choice 1
for viewing the current balance, 2 for withdrawing money, 3 for depositing money, and 4 for
exiting the main menu. Once you exit, the system will prompt for an id again. Thus, once the
system starts, it will not stop. You will need to cntrl-c to stop your program; this is ok for this
assignment. If you want your program to terminate more elegantly you can add in additional
logic, but this is not required.
Please refer to textbook for sample output pg. 401.
Account.java
import java.util.Date;
public class Account {
private int id;
private double balance;
static private double annualInterestRate = 0;
private Date dateCreated;
public Account() {
dateCreated = new Date();
}
public Account(int id, double balance) {
this.id = id;
this.balance = balance;
dateCreated = new Date();
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public static double getAnnualInterestRate() {
return annualInterestRate;
}
public static void setAnnualInterestRate(double annualInterestRate) {
Account.annualInterestRate = annualInterestRate;
}
public Date getDateCreated() {
return dateCreated;
}
public double getMonthlyInterestRate() {
double monthlyInterestRate = getAnnualInterestRate() / 1200;
return monthlyInterestRate;
}
public double getMonthlyInterest() {
double monthlyInterest= getBalance() * getMonthlyInterestRate();
return monthlyInterest;
}
public void withdraw(double amount) {
balance = getBalance() - amount;
}
public void deposit(double amount) {
balance = getBalance() + amount;
}
}
Solution
//This is your Account Class
package com.ATMBanking;
import java.util.Date;
public class Account {
private int id;
private double balance;
static private double annualInterestRate = 0;
private Date dateCreated;
public Account() {
dateCreated = new Date();
}
public Account(int id, double balance) {
this.id = id;
this.balance = balance;
dateCreated = new Date();
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public static double getAnnualInterestRate() {
return annualInterestRate;
}
public static void setAnnualInterestRate(double annualInterestRate) {
Account.annualInterestRate = annualInterestRate;
}
public Date getDateCreated() {
return dateCreat.
You are not setting any values for those variables(name, ID, interes.pdfdeepakangel
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.ne.
The java program MortgagePayment that prompts user to .pdfannamalaiagencies
/*
* The java program MortgagePayment that prompts
* user to enter purchase price, down payment,
* interest rate and number of years and then calculates
* the payment per month nad print to console and prompts
* again until user to enter n to exit.
* */
//MortgagePayment.java
import java.util.Scanner;
public class MortgagePayment {
public static void main(String[] args) {
//Create a Scanner class object
Scanner scanner=new Scanner(System.in);
//declare double type varibales and set zero
double purchasePrice = 0;
double downPayment;
double intRate = 0;
double term = 0;
double percentDP = 0;
double loanAmt;
double paymentPerMonth;
String choice = \"\";
//repeatedly prompt until user enters n to exit
do
{
System.out.println(\"Enter purchase price : \");
//prompt for purchase price and convert to double
purchasePrice=Double.parseDouble(scanner.nextLine());
System.out.println(\"Enter down payment : \");
//prompt for down payment and convert to double
downPayment=Double.parseDouble(scanner.nextLine());
System.out.println(\"Enter interest rate : \");
//prompt for interest rate and convert to double
intRate=Double.parseDouble(scanner.nextLine());
System.out.println(\"Enter years : \");
//prompt for terms and convert to double
term=Double.parseDouble(scanner.nextLine());
//Calculate Loan Amount
downPayment = purchasePrice*percentDP;
//deduct down payment from purchasePrice
loanAmt = purchasePrice-downPayment;
//calcylate paymentPerMonth
paymentPerMonth=loanAmt * (intRate/12)/(1-Math.pow(1+intRate/12, -term*12));
System.out.printf(\"Payment amount : %5.2f\ \",paymentPerMonth);
System.out.println(\"Ask user if they want to run the program again (Y or N) \");
//prompt for user choice
choice=scanner.nextLine();
}while(!choice.equals(\"n\") &&!choice.equals(\"N\"));
}//end of main method
}//end of the class MortagePayment
Sample Output:
Enter purchase price :
30
Enter down payment :
20
Enter interest rate :
15
Enter years :
10
Payment amount : 37.50
Ask user if they want to run the program again (Y or N)
y
Enter purchase price :
10000
Enter down payment :
1000
Enter interest rate :
10
Enter years :
10
Payment amount : 8333.33
Ask user if they want to run the program again (Y or N)
n
Solution
/*
* The java program MortgagePayment that prompts
* user to enter purchase price, down payment,
* interest rate and number of years and then calculates
* the payment per month nad print to console and prompts
* again until user to enter n to exit.
* */
//MortgagePayment.java
import java.util.Scanner;
public class MortgagePayment {
public static void main(String[] args) {
//Create a Scanner class object
Scanner scanner=new Scanner(System.in);
//declare double type varibales and set zero
double purchasePrice = 0;
double downPayment;
double intRate = 0;
double term = 0;
double percentDP = 0;
double loanAmt;
double paymentPerMonth;
String choice = \"\";
//repeatedly prompt until user enters n to exit
do
{
System.out.println(\"Enter purchase price : \");
//prompt for purch.
Java programI made this Account.java below. Using the attached cod.pdffathimafancy
Java program
I made this Account.java below. Using the attached code I need help with 10.7 (Game: ATM
machine)
Use the Account class created in Programming Exercise 9.7 to simulate an ATM machine.
Create ten accounts in an array with id 0, 1, . . . , 9, and initial balance $100.
The system prompts the user to enter an id. If the id is entered incorrectly, ask the user to enter a
correct id.
Once an id is accepted, the main menu is displayed as shown in the sample run.
You can enter a choice 1 for viewing the current balance, 2 for withdrawing money, 3 for
depositing money, and 4 for exiting the main menu.
Once you exit, the system will prompt for an id again. Thus, once the system starts, it will not
stop.
*/
import java.util.Date;
public class Account {
/**
* @param args
*/
private int id=0;
private double balance=0;
private double annualIntrestRate=0;
private Date dateCreated;
public Account() {
super();
}
public Account(int id, double balance) {
super();
this.id = id;
this.balance = balance;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public double getAnnualIntrestRate() {
return annualIntrestRate;
}
public void setAnnualIntrestRate(double annualIntrestRate) {
this.annualIntrestRate = annualIntrestRate;
}
public Date getDateCreated() {
return dateCreated;
}
public void setDateCreated(Date dateCreated) {
this.dateCreated = dateCreated;
}
public double getMonthlyInterestRate()
{
return (this.getAnnualIntrestRate()/12);
}
public double getMonthlyInterest()
{
return (getBalance() *getMonthlyInterestRate()/100);
}
public double withDraw(double balance)
{
this.setBalance(this.getBalance()-balance);
return this.getBalance();
}
public double diposite(double balance)
{
this.setBalance(this.getBalance()+balance);
return this.getBalance();
}
public double totalBalance()
{
balance =balance + getMonthlyInterest();
return balance;
}
}
//AccountTest.java
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;
public class AccountTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
Account ac=new Account(1,5000.00);
System.out.println(\"Enter the annual intrest rate\");
double intrestRate=sc.nextDouble();
ac.setAnnualIntrestRate(intrestRate);
Date d=new Date();
Calendar currentDate = Calendar.getInstance();
ac.setDateCreated(currentDate.getTime());
System.out.println(\"Date id \"+ac.getDateCreated());
System.out.println(\"Monthly intrest rate is :\"+ac.getMonthlyInterestRate());
System.out.println(\"Monthly intrest is :\"+ac.getMonthlyInterest());
System.out.println(\"Enter Amount for diposite \");
double dipositeAmount=sc.nextDouble();
System.out.println(\"The amount after diposite is :\"+ac.diposite(dipositeAmount));
System.out.println(\"Enter Amount to withdraw :\");
double withdramount= sc.nextDouble.
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 .
Consider this C++ BankAccount class with the following public member.pdfarchigallery1298
Consider this C++ BankAccount class with the following public member functions.
/* Constructs an object to represent a bank account.
*
* Parameter:
* double initial_balance -- the starting balance of the account
* /
BankAccount(double initial_balance);
/* Adds a certain amount the balance of the account.
*
* Parameter:
* double amount -- the amount to add to the balance
*
* Returns:
* nothing
*/
void deposit(double amount);
/* Subtracts a certain amount from the balance of the account.
*
* Parameter:
* double amount -- the amount to subtract from the balance
*
* Returns:
* nothing
*/
void withdraw(double amount);
/* Gets the balance of the account.
*
* Parameters:
* none
*
* Returns:
* double -- the balance of the account
*/
double get_balance();
(a) Which are the accessor function(s)?
(b) Which are the mutator function(s)?
(c) Create an object to represent a checking account with a starting balance of $1500.
(d) Provide a fragment of C++ code to perform this sequence of actions on the checking
account: deposit $100, print the balance, withdraw $250.
Solution
a) accessors
get_balance()
b) mutators
void deposit(double)
void withdraw(double)
c) BankAccount acc(1500.0);
d) acc.deposit(100.0)
acc.get_balance();
acc.withdraw(250.0).
I need help creating a basic and simple Java program. Here is the ex.pdfrajeshjangid1865
I need help creating a basic and simple Java program. Here is the exercise. I have included my
Account class that is referred to at the bottom, below the exercise.
Use the Account class created in Programming Exercise 9.7 to simulate an ATM machine.
Create ten accounts in an array with id 0, 1, . . . , 9, and initial balance $100. The system prompts
the user to enter an id. If the id is entered incorrectly, ask the user to enter a correct id. Once an
id is accepted, the main menu is displayed as shown in the sample run. You can enter a choice 1
for viewing the current balance, 2 for withdrawing money, 3 for depositing money, and 4 for
exiting the main menu. Once you exit, the system will prompt for an id again. Thus, once the
system starts, it will not stop. You will need to cntrl-c to stop your program; this is ok for this
assignment. If you want your program to terminate more elegantly you can add in additional
logic, but this is not required.
Please refer to textbook for sample output pg. 401.
Account.java
import java.util.Date;
public class Account {
private int id;
private double balance;
static private double annualInterestRate = 0;
private Date dateCreated;
public Account() {
dateCreated = new Date();
}
public Account(int id, double balance) {
this.id = id;
this.balance = balance;
dateCreated = new Date();
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public static double getAnnualInterestRate() {
return annualInterestRate;
}
public static void setAnnualInterestRate(double annualInterestRate) {
Account.annualInterestRate = annualInterestRate;
}
public Date getDateCreated() {
return dateCreated;
}
public double getMonthlyInterestRate() {
double monthlyInterestRate = getAnnualInterestRate() / 1200;
return monthlyInterestRate;
}
public double getMonthlyInterest() {
double monthlyInterest= getBalance() * getMonthlyInterestRate();
return monthlyInterest;
}
public void withdraw(double amount) {
balance = getBalance() - amount;
}
public void deposit(double amount) {
balance = getBalance() + amount;
}
}
Solution
//This is your Account Class
package com.ATMBanking;
import java.util.Date;
public class Account {
private int id;
private double balance;
static private double annualInterestRate = 0;
private Date dateCreated;
public Account() {
dateCreated = new Date();
}
public Account(int id, double balance) {
this.id = id;
this.balance = balance;
dateCreated = new Date();
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public static double getAnnualInterestRate() {
return annualInterestRate;
}
public static void setAnnualInterestRate(double annualInterestRate) {
Account.annualInterestRate = annualInterestRate;
}
public Date getDateCreated() {
return dateCreat.
You are not setting any values for those variables(name, ID, interes.pdfdeepakangel
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.ne.
The java program MortgagePayment that prompts user to .pdfannamalaiagencies
/*
* The java program MortgagePayment that prompts
* user to enter purchase price, down payment,
* interest rate and number of years and then calculates
* the payment per month nad print to console and prompts
* again until user to enter n to exit.
* */
//MortgagePayment.java
import java.util.Scanner;
public class MortgagePayment {
public static void main(String[] args) {
//Create a Scanner class object
Scanner scanner=new Scanner(System.in);
//declare double type varibales and set zero
double purchasePrice = 0;
double downPayment;
double intRate = 0;
double term = 0;
double percentDP = 0;
double loanAmt;
double paymentPerMonth;
String choice = \"\";
//repeatedly prompt until user enters n to exit
do
{
System.out.println(\"Enter purchase price : \");
//prompt for purchase price and convert to double
purchasePrice=Double.parseDouble(scanner.nextLine());
System.out.println(\"Enter down payment : \");
//prompt for down payment and convert to double
downPayment=Double.parseDouble(scanner.nextLine());
System.out.println(\"Enter interest rate : \");
//prompt for interest rate and convert to double
intRate=Double.parseDouble(scanner.nextLine());
System.out.println(\"Enter years : \");
//prompt for terms and convert to double
term=Double.parseDouble(scanner.nextLine());
//Calculate Loan Amount
downPayment = purchasePrice*percentDP;
//deduct down payment from purchasePrice
loanAmt = purchasePrice-downPayment;
//calcylate paymentPerMonth
paymentPerMonth=loanAmt * (intRate/12)/(1-Math.pow(1+intRate/12, -term*12));
System.out.printf(\"Payment amount : %5.2f\ \",paymentPerMonth);
System.out.println(\"Ask user if they want to run the program again (Y or N) \");
//prompt for user choice
choice=scanner.nextLine();
}while(!choice.equals(\"n\") &&!choice.equals(\"N\"));
}//end of main method
}//end of the class MortagePayment
Sample Output:
Enter purchase price :
30
Enter down payment :
20
Enter interest rate :
15
Enter years :
10
Payment amount : 37.50
Ask user if they want to run the program again (Y or N)
y
Enter purchase price :
10000
Enter down payment :
1000
Enter interest rate :
10
Enter years :
10
Payment amount : 8333.33
Ask user if they want to run the program again (Y or N)
n
Solution
/*
* The java program MortgagePayment that prompts
* user to enter purchase price, down payment,
* interest rate and number of years and then calculates
* the payment per month nad print to console and prompts
* again until user to enter n to exit.
* */
//MortgagePayment.java
import java.util.Scanner;
public class MortgagePayment {
public static void main(String[] args) {
//Create a Scanner class object
Scanner scanner=new Scanner(System.in);
//declare double type varibales and set zero
double purchasePrice = 0;
double downPayment;
double intRate = 0;
double term = 0;
double percentDP = 0;
double loanAmt;
double paymentPerMonth;
String choice = \"\";
//repeatedly prompt until user enters n to exit
do
{
System.out.println(\"Enter purchase price : \");
//prompt for purch.
Change to oop formatimport java.util.Scanner;import java.io.;.pdfMAYANKBANSAL1981
Change to oop format
import java.util.Scanner;
import java.io.*;
import java.text.DecimalFormat;
public class Amortization {
/* call values in, set balance and principle. set month to increment until reaching number
provided. use \t to space out result well.
Use PritWriter output instead of System.output to make the notepad file.*/
public static void createReport(String filename, double loan, double interestRate, int years)
throws IOException {
PrintWriter output = new PrintWriter(new FileWriter(filename));
double monthlyPayment = calcPayment(loan, interestRate, years);
int numberOfPayments = getNumberOfPayments(years);
double balance = loan;
output.println("{Monthly Payment}: " + monthlyPayment);
output.println("{Month} \t {Interest} \t {Principal} \t {Balance}");
for (int month = 1; month <= numberOfPayments; month++) {
double interest = balance * (interestRate / 12);
double principal = monthlyPayment - interest;
balance -= principal;
output.printf("%d \t \t %.2f \t \t %.2f \t \t %.2f \\\n", month, interest, principal, balance);
}
output.close();
}
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
DecimalFormat df = new DecimalFormat("#.##");
do {
/* Data members */
double loan;
int years;
double interestRate;
/* Get amount, interest rate, and years from the user */
System.out.println("Enter the loan amount: ");
loan = keyboard.nextDouble();
System.out.println("Enter the annual interest rate: ");
interestRate = keyboard.nextDouble() / 100.0;
System.out.println("Enter the years of the loan: ");
years = keyboard.nextInt();
double payment = calcPayment(loan, interestRate, years);
if (payment < 0) {
System.out.println("Invalid input values.");
} else {
System.out.println("Monthly Payment: " + df.format(payment));
int numberOfPayments = getNumberOfPayments(years);
System.out.println("Total Number of Payments: " + numberOfPayments);
try {
createReport("LoanAmortization.txt", loan, interestRate, years);
System.out.println("Report created successfully.");
} catch (IOException e)
{
System.out.println("Error creating report: " + e.getMessage());
}
}
System.out.println("Would you like to run another report? Enter Y for yes or N for no: ");
} while (keyboard.next().equalsIgnoreCase("Y"));
keyboard.close();
}
public static double calcPayment(double loan, double interestRate, int years) {
double term = Math.pow(1 + (interestRate / 12), years * 12);
double payment = (loan * (interestRate / 12) * term) / (term - 1);
return payment;
}
public static int getNumberOfPayments(int years) {
return years * 12; // Assuming monthly payments for the given number of years
}
public static void createReport(String filename) throws IOException {
// Sample implementation to save data to a file
PrintWriter out = new PrintWriter(new FileWriter(filename, true));
out.println("Sample Data");
out.close();
}
}.
The java program that simulates ATM operations. The prog.pdfpoddaranand1
/**
* The java program that simulates ATM operations.
* The program display a menu of choices.
* The prompt to enter operation to perform
* and then print the balance after the transaction
* to console.
* */
//AtmSimDoLoop.java
import java.util.Scanner;
public class AtmSimDoLoop {
public static void main(String[] args) {
//Create a Scanner class object
Scanner scanner=new Scanner(System.in);
//declare variables
double balance=0;
int userChoice;
double deposit;
double withdrawl;
//set repeat =true
boolean repeat=true;
//prompt and repeat until user enters 4 to exit
do {
System.out.println(\"Enter the number of your desired transaction type.\");
System.out.println(\"1.Balance\");
System.out.println(\"2.Deposit\");
System.out.println(\"3.Withdrawl\");
System.out.println(\"4.Quit\");
userChoice=Integer.parseInt(scanner.nextLine());
//using switch case to select an appropriate choice
switch (userChoice) {
case 1:
System.out.println(\"Your current balance is \"+balance);
break;
case 2:
System.out.println(\"Enter the amount of the deposit \");
deposit=Double.parseDouble(scanner.nextLine());
balance+=deposit;
System.out.println(\"Your current balance is \"+balance);
break;
case 3:
System.out.println(\"Enter the amount of the withdrawl \");
withdrawl=Double.parseDouble(scanner.nextLine());
if(withdrawl<=balance)
{
balance-=withdrawl;
System.out.println(\"Your current balance is \"+balance);
}
else
System.out.println(\"Insufficient funds. Your current balance is \"+balance+\".\");
break;
case 4:
System.out.println(\"Good-bye.\");
//set repeat=false
repeat=false;
}
} while (repeat);
}//end of main
}//end of class AtmSimDoLoop
------------------------------------------------------------------------------------------------------------
Sample output:
Enter the number of your desired transaction type.
1.Balance
2.Deposit
3.Withdrawl
4.Quit
1
Your current balance is 0.0
Enter the number of your desired transaction type.
1.Balance
2.Deposit
3.Withdrawl
4.Quit
2
Enter the amount of the deposit
500
Your current balance is 500.0
Enter the number of your desired transaction type.
1.Balance
2.Deposit
3.Withdrawl
4.Quit
3
Enter the amount of the withdrawl
300
Your current balance is 200.0
Enter the number of your desired transaction type.
1.Balance
2.Deposit
3.Withdrawl
4.Quit
3
Enter the amount of the withdrawl
300
Insufficient funds. Your current balance is 200.0.
Enter the number of your desired transaction type.
1.Balance
2.Deposit
3.Withdrawl
4.Quit
4
Good-bye.
Solution
/**
* The java program that simulates ATM operations.
* The program display a menu of choices.
* The prompt to enter operation to perform
* and then print the balance after the transaction
* to console.
* */
//AtmSimDoLoop.java
import java.util.Scanner;
public class AtmSimDoLoop {
public static void main(String[] args) {
//Create a Scanner class object
Scanner scanner=new Scanner(System.in);
//declare variables
double balance=0;
int userChoice;
double deposit;
double withdrawl;
//set repeat =tr.
CSC139 Chapter 9 Lab Assignments (1) Classes and Obj.docxruthannemcmullen
CSC139 Chapter 9 Lab Assignments (1)
Classes and Objects
Objectives
In this lab assignment, students will learn:
- How to design and define class
- How to create object
- How to define a tester program to test the object
Goals
In this lab assignment, students will demonstrate the abilities to:
- Design and define class
- Create object
- Define a tester program to test the object
Grading
- Design and create a GUI (20 pts)
- Design and define class (40 pts)
- Define tester program (40 pts)
Develop a "
BankAccount
" windows form project, which will allow user to
- Enter amount of money to deposit, withdraw or move
- Deposit money in checking or savings account.
- Withdraw money from checking or savings account.
- Move money between checking account and saving account.
- View the new balance on the form after each transaction.
Here is sample input/output:
When start to run project, initial balances for both checking and saving accounts ($1000.00) should be displayed on the form.
After deposit $500.00 to checking account.
After move $800.00 from saving to checking account.
If user attempts to withdraw $4000.00 from checking account at this moment, a MessageBox should be displayed with an error message.
Project specifications --------
1. This project should perform object-oriented programming.
Add a class file "Account.vb" to define class "Account", rename "Form1.vb" file as "AccountTesterForm.vb" which will create account object and test the object’s attributes and behaviors.
2.
This is the GUI for the bank. The amount of money need to be entered from the textbox, each button represents a type of transaction. The new balance will be displayed on the form after each transaction.
Please use the same control names in order to use the tester program code below.
balanceLabel
amountTextBox
moveStoCButton
withdrawSavingButton
depositSavingButton
moveCtoSButton
depositCheckingButton
withdrawCheckingButton
3.
Here is the definition of class Account, some codes are missing, you may copy the code to your project in Visual Studio and complete the missing code.
Public Class Account
Private savingBalance As Decimal 'instance variable for balance in saving account
Private checkingBalance As Decimal 'instance variable for balance in checking account
'constructor which initialize balances in both accounts to 1000.00
Public Sub New()
savingBalance = 1000.0
checkingBalance = 1000.0
End Sub
'property for savingBalance
Public Property Saving() As Double
Get
Return savingBalance
End Get
Set(ByVal value As Double)
If value < 0 Then
savingBalance = 0
Else
savingBalance = value
End If
End Set
End Property
'property for checkingBalance
Public Property Checking() As Double
'write your code here
End Property
'define how to deposit money to checking a.
The java Payroll that prompts user to enter hourly rate .pdfangelfashions02
/**
* The java Payroll that prompts user to enter
* hourly rate of pay and number of hours worked.
* Then calculates the gross pay and net pay
* and print to console.
* */
//Payroll.java
import java.util.Scanner;
public class Payroll
{
public static void main(String[] args)
{
//declare variables for hourly rate and hours worked
double hourlyRate;
int hoursWorked;
//Set tax rate as 0.15 (15 percent )
final double WITH_HOLD_TAX=0.15;
//Set grossPay=0
double grossPay=0;
//Set tax =0
double tax=0;
//Set netPay=0
double netPay=0;
//Create an instance of Scanner class
Scanner inputScanner =new Scanner(System.in);
System.out.println(\"Enter hourly rate of pay\");
//prompt for hourly rate
hourlyRate=Integer.parseInt(inputScanner.nextLine());
System.out.println(\"Enter number of hours worked\");
//prompt for number of hours
hoursWorked=Integer.parseInt(inputScanner.nextLine());
//Calculate grossPay
//multiply hoursWorked by hourlyRate
grossPay=hoursWorked*hourlyRate;
//calculate with hold tax
tax=grossPay*WITH_HOLD_TAX;
//calculate netPay
//subtract tax from grossPay
netPay=grossPay-tax;
//print gross pay and net pay to console
System.out.println(\"Gross Pay : \"+grossPay);
System.out.println(\"Net pay : \"+netPay);
}
}
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
Sample output:
Enter hourly rate of pay
10
Enter number of hours worked
50
Gross Pay : 500.0
Net pay : 425.0
Solution
/**
* The java Payroll that prompts user to enter
* hourly rate of pay and number of hours worked.
* Then calculates the gross pay and net pay
* and print to console.
* */
//Payroll.java
import java.util.Scanner;
public class Payroll
{
public static void main(String[] args)
{
//declare variables for hourly rate and hours worked
double hourlyRate;
int hoursWorked;
//Set tax rate as 0.15 (15 percent )
final double WITH_HOLD_TAX=0.15;
//Set grossPay=0
double grossPay=0;
//Set tax =0
double tax=0;
//Set netPay=0
double netPay=0;
//Create an instance of Scanner class
Scanner inputScanner =new Scanner(System.in);
System.out.println(\"Enter hourly rate of pay\");
//prompt for hourly rate
hourlyRate=Integer.parseInt(inputScanner.nextLine());
System.out.println(\"Enter number of hours worked\");
//prompt for number of hours
hoursWorked=Integer.parseInt(inputScanner.nextLine());
//Calculate grossPay
//multiply hoursWorked by hourlyRate
grossPay=hoursWorked*hourlyRate;
//calculate with hold tax
tax=grossPay*WITH_HOLD_TAX;
//calculate netPay
//subtract tax from grossPay
netPay=grossPay-tax;
//print gross pay and net pay to console
System.out.println(\"Gross Pay : \"+grossPay);
System.out.println(\"Net pay : \"+netPay);
}
}
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
Sample output:
E.
Banks offer various types of accounts, such as savings, checking, cer.pdfrajeshjain2109
Banks offer various types of accounts, such as savings, checking, certificate of deposits, and
money market, to attract customers as well as meet their specific needs. Two of the most
commonly used accounts are savings and checking. Each of these accounts has various options.
For example, you may have a savings account that requires no minimum balance but has a lower
interest rate. Similarly, you may have a checking account that limits the number of checks you
may write. Another type of account that is used to save money for the long term is certificate of
deposit (CD). In this programming exercise, you use abstract classes and pure virtual functions to
design classes to manipulate various types of accounts. For simplicity assume that the bank
offers three types of accounts: savings, checking, and certificate of deposit, as described next.
Savings accounts: Suppose that the bank offers two types of savings accounts: one that has no
minimum balance and a lower interest rate and another that requires a minimum balance and has
a higher interest rate Checking accounts: Suppose that the bank offers three types of checking
accounts: one with a monthly service charge, limited check writing, no minimum balance, and no
interest, another with no monthly service charge, a minimum balance requirement, unlimited
check writing and lower interest, and a third with no monthly service charge, a higher minimum
requirement, a higher interest rate, and unlimited check writing Certificate of deposit (CD): In an
account of this type, money is left for some time, and these accounts draw higher interest rates
than savings or checking accounts. Suppose that you purchase a CD for six months. Then we say
that the CD will mature in six months. The penalty
Solution
#include
#include
using namespace std;
class bankAccount
{
private:
string accHolderName;
string accountType;
int accountNumber;
double accBalance;
public:
bankAccount(string fullName = \"\", string accType = \"\", int accNum = 0, double balance =
0.0);
string getAccHolderName() const;
string getAccountType() const;
int getAccountNumber() const;
double getAccBalance() const;
void deposit(double amount);
void withdrawl(double amount);
virtual void print() const = 0;
};
/*contructor*/
bankAccount::bankAccount(string fullName, string accType, int accNum, double balance) {
accHolderName = fullName;
accountType = accType;
accountNumber = accNum;
accBalance = balance;
}
string bankAccount::getAccHolderName() const{
return accHolderName;
}
string bankAccount::getAccountType() const{
return accountType;
}
int bankAccount::getAccountNumber() const{
return accountNumber;
}
double bankAccount::getAccBalance() const{
return accBalance;
}
void bankAccount::deposit(double amount) {
accBalance += amount;
}
void bankAccount::withdrawl(double amount) {
if (amount > accBalance) {
cout << \"Insufficent Funds. Account balance: \" << accBalance << endl;
} else {
accBalance -= amount;
}
}
class checkingAccount: public bankAccount
{.
Create a new Java project and add the Account class into the source co.pdfadmin618513
Create a new Java project and add the Account class into the source code.
Create a JUnit test class, AccountTest , and write test cases which exercise all the methods of the
Account class.
Compile your classes and run the JUnit tests.
If your tests reveal any defects in the logic of the Account class, report them.
here are account.java file
import java.text.NumberFormat;
/**
* Account is a bank account with basic services for deposit,
* withdrawal, and interest.
*/
public class Account
{
private NumberFormat fmt = NumberFormat.getCurrencyInstance();
private final float kInterestRate = 0.045f; // interest rate of 4.5%
private long acctNumber;
private float balance;
public final String name;
/**
* Sets up the account by defining its owner, account number,
* and initial balance.
* @param owner name of account holder
* @param account the account number, an identifier for the account
* @param initial the initial amount of money in the account.
*/
public Account(String owner, long account, float initial)
{
name = owner;
acctNumber = account;
balance = initial;
}
/**
* Deposit the specified amount into the account.
* @param amount value to be added to the balance
* @return true if amount is non-negative, false if amount
* is negative; indicates balance was not changed.
*/
public boolean deposit(float amount)
{
boolean result = true;
// is amount invalid?
if (amount < 0)
{
result = false;
}
else
{
balance = balance + amount;
}
return result;
}
/**
* Withdraw the specified amount from the account,
* unless amount is negative, fee is negative, or
* amount exceeds current balance.
* @param amount value to be deducted from the balance
* @param fee the transaction fee debited from the account
* @return true if transaction was successful, false otherwise;
*/
public boolean withdraw(float amount, float fee)
{
// validate parameters
if (isValidWithdrawl(amount, fee))
{
amount += fee;
balance = balance - amount;
}
return isValidWithdrawl(amount, fee);
}
/* Determine if withdrawal parameters are valid */
private boolean isValidWithdrawl(float amount, float fee)
{
return amount >= 0 && fee >= 0 && amount <= balance;
}
/**
* Adds interest to the account.
*/
public void addInterest()
{
balance += (balance * kInterestRate);
}
/**
* Accessor to the current balance of the account.
* @return the current balance of the account.
*/
public float getBalance()
{
return balance;
}
/**
* Accessor to the account number.
* @return the account number.
*/
public long getAccountNumber()
{
return acctNumber;
}
/**
* Returns a one-line description of the account as a string.
* @return formatted account information
*/
public String toString()
{
return (acctNumber + "\t" + name + "\t" + fmt.format(balance));
}
}.
Please distinguish between the .h and .cpp file, create a fully work.pdfneerajsachdeva33
Please distinguish between the .h and .cpp file, create a fully working c++ program using the
diagram provided.
Section 1: Homework Objectives
1. Given a class UML, learn to write a C++ class declaration.
2. Learn how to define/call constructor, accessor, mutator or toString( )
Section 2: Background
In this homework, according to the given UML class diagram, you’re required to design a
BankAccount class. You are also required to write a driver’s program to test it.
Section 3: Program description
3.1 Introduction
According to the following UML diagram, design a BankAccount class.
BankAccount
-id: string = \"?\"
-balance: double = 0.0
-address: string = \"?\"
+BankAccount()
+BankAccount(string, double, string)
+getID(): string
+getBalance(): double
+getAddress(): string
+setID(string): void
+deposit(double): bool
+withdraw(double): bool
+updateAddress(string):void
+toString(): string
+addInterest(): void
+equals(BankAccount): bool
Member variables and member functions\' description
Member
Variable
Data Type
Description
id
string
This represents a bank account\'s unique ID, such as \"123-456-
789\"
balance
double
This is the account balance.
address
string
This represents a bank account customer\'s mailing address, such as \"12345 Via Linda Rd.
Phoenix, AZ 85048\"
Member Function
Function Description
BankAccount()
This is the default constructor and it should initialize all member varible by the initial value
defined inside the UML. For example, id should be initialized to \"?\" etc.
BankAccount(string newID, double newBal, string newAddress)
This is the overloadded constructor. It takes three input parameters and initialize the three
member variables accordingly with the three input parameters.
string getID()
This is the accessor for member variable id
double getBalance()
This is the accessor for member variable balance
string getAddress()
This is the accessor for member variable address
void setID(string newID)
This is the mutator for member variable id. It takes a new id as input and change the member
variable id accordingly
bool deposit(double amount)
This is a mutator for member variable balance. It takes an amount as input parameter, if the
amount of deposit is negative, the balance will not be changed and the function should return
false; otherwise, the deposited amount (parameter value) will be added to the balance and the
function returns true.
bool withdraw(double amount)
This is a mutator for member variable balance. It takes an amount as input parameter, if the
balance is less than the withdraw amount (parameter value) or the withdraw amount is less than
zero, the function should return false, otherwise subtract the balance by withdraw amount and
return true.
void updateAddress(string newAddress)
This is a mutator for member variable address. In case the bank account\'s customer want to
change his/her address, we will use this function.
string toString()
The toString function will display an bank account info. in the following format.
The complexity of frontend applications over the years led to the creation of more robust solutions, where data logic won’t be messed up at scale. A shift took place from the traditional services approach, in which data is tightly coupled to the Views of their Components, towards more composable and shareable solutions. Each of these solutions is what we call a "state-manager".
Goal of this presentation is the comparative analysis between different react frontend state managers such as Redux, MobX, Recoil and React-Query. State Machines will also be presented, showing a completely different perception of how state can be orchestrated. Different mental models of the aforementioned state managers along with their different technical implementations will be presented to the audience. Ultimately, the audience can use this presentation for future reference on faster deciding which state-manager fits their own projects. Before delving into the comparison there will be a description of the main data flow in the browser. Concepts like reactivity, immutability, predictability, concurrency and performance will be detected on the main flow and will act as our comparison metrics among the state-managers.
This is Due to highest Cncentration of Comon Ions.pdfannaindustries
This is Due to highest Cncentration of Comon Ions(SO42-) The reason is
\"Common Ion Effect\" (NH4)2SO4 has highest concentration of SO42-
Solution
This is Due to highest Cncentration of Comon Ions(SO42-) The reason is
\"Common Ion Effect\" (NH4)2SO4 has highest concentration of SO42-.
There is no reaction. The nearest I can think of .pdfannaindustries
There is no reaction. The nearest I can think of involving the above is: MgCl2 + 2
NaOH = Mg(OH)2 + 2 NaCl
Solution
There is no reaction. The nearest I can think of involving the above is: MgCl2 + 2
NaOH = Mg(OH)2 + 2 NaCl.
The decomposition of hydrogen peroxide to gaseous.pdfannaindustries
The decomposition of hydrogen peroxide to gaseous O2 and water is a spontaneous
process only means H2O2 is thermodynamically unstable. The fact that H2O2 is stable for long
periods of time indicates that H2O2 is kinetically stable. Thus. Adding catalyst will speed the
decomposition reaction up cause it decreases the activation energy.
Solution
The decomposition of hydrogen peroxide to gaseous O2 and water is a spontaneous
process only means H2O2 is thermodynamically unstable. The fact that H2O2 is stable for long
periods of time indicates that H2O2 is kinetically stable. Thus. Adding catalyst will speed the
decomposition reaction up cause it decreases the activation energy..
Im not entirely sure what this is asking. I ass.pdfannaindustries
I\'m not entirely sure what this is asking. I assume these are two processes being
performed on the molecule shown. I\'ve seen similar reactions and not exactly the same thing.
OsO4 usually adds OH cis if I recall to the inner carbons, but the OH groups are already there.
The second part of that might add SO2? For question 2 I\'m almost certain that the initial reaction
removes the OH groups on the original molecule and makes it into an epoxide. adding hydroxide
and H20 would make it a basic environment so an H+ in solution would protonate the epoxide.
OH would attach wherever the bond to the protonated epoxide was weakest, resulting in the
initial molecule with one of the centers having inverted stereochemistry 40% sure on all of this at
best. I just had my orgo final. good luck on yours :)
Solution
I\'m not entirely sure what this is asking. I assume these are two processes being
performed on the molecule shown. I\'ve seen similar reactions and not exactly the same thing.
OsO4 usually adds OH cis if I recall to the inner carbons, but the OH groups are already there.
The second part of that might add SO2? For question 2 I\'m almost certain that the initial reaction
removes the OH groups on the original molecule and makes it into an epoxide. adding hydroxide
and H20 would make it a basic environment so an H+ in solution would protonate the epoxide.
OH would attach wherever the bond to the protonated epoxide was weakest, resulting in the
initial molecule with one of the centers having inverted stereochemistry 40% sure on all of this at
best. I just had my orgo final. good luck on yours :).
Change to oop formatimport java.util.Scanner;import java.io.;.pdfMAYANKBANSAL1981
Change to oop format
import java.util.Scanner;
import java.io.*;
import java.text.DecimalFormat;
public class Amortization {
/* call values in, set balance and principle. set month to increment until reaching number
provided. use \t to space out result well.
Use PritWriter output instead of System.output to make the notepad file.*/
public static void createReport(String filename, double loan, double interestRate, int years)
throws IOException {
PrintWriter output = new PrintWriter(new FileWriter(filename));
double monthlyPayment = calcPayment(loan, interestRate, years);
int numberOfPayments = getNumberOfPayments(years);
double balance = loan;
output.println("{Monthly Payment}: " + monthlyPayment);
output.println("{Month} \t {Interest} \t {Principal} \t {Balance}");
for (int month = 1; month <= numberOfPayments; month++) {
double interest = balance * (interestRate / 12);
double principal = monthlyPayment - interest;
balance -= principal;
output.printf("%d \t \t %.2f \t \t %.2f \t \t %.2f \\\n", month, interest, principal, balance);
}
output.close();
}
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
DecimalFormat df = new DecimalFormat("#.##");
do {
/* Data members */
double loan;
int years;
double interestRate;
/* Get amount, interest rate, and years from the user */
System.out.println("Enter the loan amount: ");
loan = keyboard.nextDouble();
System.out.println("Enter the annual interest rate: ");
interestRate = keyboard.nextDouble() / 100.0;
System.out.println("Enter the years of the loan: ");
years = keyboard.nextInt();
double payment = calcPayment(loan, interestRate, years);
if (payment < 0) {
System.out.println("Invalid input values.");
} else {
System.out.println("Monthly Payment: " + df.format(payment));
int numberOfPayments = getNumberOfPayments(years);
System.out.println("Total Number of Payments: " + numberOfPayments);
try {
createReport("LoanAmortization.txt", loan, interestRate, years);
System.out.println("Report created successfully.");
} catch (IOException e)
{
System.out.println("Error creating report: " + e.getMessage());
}
}
System.out.println("Would you like to run another report? Enter Y for yes or N for no: ");
} while (keyboard.next().equalsIgnoreCase("Y"));
keyboard.close();
}
public static double calcPayment(double loan, double interestRate, int years) {
double term = Math.pow(1 + (interestRate / 12), years * 12);
double payment = (loan * (interestRate / 12) * term) / (term - 1);
return payment;
}
public static int getNumberOfPayments(int years) {
return years * 12; // Assuming monthly payments for the given number of years
}
public static void createReport(String filename) throws IOException {
// Sample implementation to save data to a file
PrintWriter out = new PrintWriter(new FileWriter(filename, true));
out.println("Sample Data");
out.close();
}
}.
The java program that simulates ATM operations. The prog.pdfpoddaranand1
/**
* The java program that simulates ATM operations.
* The program display a menu of choices.
* The prompt to enter operation to perform
* and then print the balance after the transaction
* to console.
* */
//AtmSimDoLoop.java
import java.util.Scanner;
public class AtmSimDoLoop {
public static void main(String[] args) {
//Create a Scanner class object
Scanner scanner=new Scanner(System.in);
//declare variables
double balance=0;
int userChoice;
double deposit;
double withdrawl;
//set repeat =true
boolean repeat=true;
//prompt and repeat until user enters 4 to exit
do {
System.out.println(\"Enter the number of your desired transaction type.\");
System.out.println(\"1.Balance\");
System.out.println(\"2.Deposit\");
System.out.println(\"3.Withdrawl\");
System.out.println(\"4.Quit\");
userChoice=Integer.parseInt(scanner.nextLine());
//using switch case to select an appropriate choice
switch (userChoice) {
case 1:
System.out.println(\"Your current balance is \"+balance);
break;
case 2:
System.out.println(\"Enter the amount of the deposit \");
deposit=Double.parseDouble(scanner.nextLine());
balance+=deposit;
System.out.println(\"Your current balance is \"+balance);
break;
case 3:
System.out.println(\"Enter the amount of the withdrawl \");
withdrawl=Double.parseDouble(scanner.nextLine());
if(withdrawl<=balance)
{
balance-=withdrawl;
System.out.println(\"Your current balance is \"+balance);
}
else
System.out.println(\"Insufficient funds. Your current balance is \"+balance+\".\");
break;
case 4:
System.out.println(\"Good-bye.\");
//set repeat=false
repeat=false;
}
} while (repeat);
}//end of main
}//end of class AtmSimDoLoop
------------------------------------------------------------------------------------------------------------
Sample output:
Enter the number of your desired transaction type.
1.Balance
2.Deposit
3.Withdrawl
4.Quit
1
Your current balance is 0.0
Enter the number of your desired transaction type.
1.Balance
2.Deposit
3.Withdrawl
4.Quit
2
Enter the amount of the deposit
500
Your current balance is 500.0
Enter the number of your desired transaction type.
1.Balance
2.Deposit
3.Withdrawl
4.Quit
3
Enter the amount of the withdrawl
300
Your current balance is 200.0
Enter the number of your desired transaction type.
1.Balance
2.Deposit
3.Withdrawl
4.Quit
3
Enter the amount of the withdrawl
300
Insufficient funds. Your current balance is 200.0.
Enter the number of your desired transaction type.
1.Balance
2.Deposit
3.Withdrawl
4.Quit
4
Good-bye.
Solution
/**
* The java program that simulates ATM operations.
* The program display a menu of choices.
* The prompt to enter operation to perform
* and then print the balance after the transaction
* to console.
* */
//AtmSimDoLoop.java
import java.util.Scanner;
public class AtmSimDoLoop {
public static void main(String[] args) {
//Create a Scanner class object
Scanner scanner=new Scanner(System.in);
//declare variables
double balance=0;
int userChoice;
double deposit;
double withdrawl;
//set repeat =tr.
CSC139 Chapter 9 Lab Assignments (1) Classes and Obj.docxruthannemcmullen
CSC139 Chapter 9 Lab Assignments (1)
Classes and Objects
Objectives
In this lab assignment, students will learn:
- How to design and define class
- How to create object
- How to define a tester program to test the object
Goals
In this lab assignment, students will demonstrate the abilities to:
- Design and define class
- Create object
- Define a tester program to test the object
Grading
- Design and create a GUI (20 pts)
- Design and define class (40 pts)
- Define tester program (40 pts)
Develop a "
BankAccount
" windows form project, which will allow user to
- Enter amount of money to deposit, withdraw or move
- Deposit money in checking or savings account.
- Withdraw money from checking or savings account.
- Move money between checking account and saving account.
- View the new balance on the form after each transaction.
Here is sample input/output:
When start to run project, initial balances for both checking and saving accounts ($1000.00) should be displayed on the form.
After deposit $500.00 to checking account.
After move $800.00 from saving to checking account.
If user attempts to withdraw $4000.00 from checking account at this moment, a MessageBox should be displayed with an error message.
Project specifications --------
1. This project should perform object-oriented programming.
Add a class file "Account.vb" to define class "Account", rename "Form1.vb" file as "AccountTesterForm.vb" which will create account object and test the object’s attributes and behaviors.
2.
This is the GUI for the bank. The amount of money need to be entered from the textbox, each button represents a type of transaction. The new balance will be displayed on the form after each transaction.
Please use the same control names in order to use the tester program code below.
balanceLabel
amountTextBox
moveStoCButton
withdrawSavingButton
depositSavingButton
moveCtoSButton
depositCheckingButton
withdrawCheckingButton
3.
Here is the definition of class Account, some codes are missing, you may copy the code to your project in Visual Studio and complete the missing code.
Public Class Account
Private savingBalance As Decimal 'instance variable for balance in saving account
Private checkingBalance As Decimal 'instance variable for balance in checking account
'constructor which initialize balances in both accounts to 1000.00
Public Sub New()
savingBalance = 1000.0
checkingBalance = 1000.0
End Sub
'property for savingBalance
Public Property Saving() As Double
Get
Return savingBalance
End Get
Set(ByVal value As Double)
If value < 0 Then
savingBalance = 0
Else
savingBalance = value
End If
End Set
End Property
'property for checkingBalance
Public Property Checking() As Double
'write your code here
End Property
'define how to deposit money to checking a.
The java Payroll that prompts user to enter hourly rate .pdfangelfashions02
/**
* The java Payroll that prompts user to enter
* hourly rate of pay and number of hours worked.
* Then calculates the gross pay and net pay
* and print to console.
* */
//Payroll.java
import java.util.Scanner;
public class Payroll
{
public static void main(String[] args)
{
//declare variables for hourly rate and hours worked
double hourlyRate;
int hoursWorked;
//Set tax rate as 0.15 (15 percent )
final double WITH_HOLD_TAX=0.15;
//Set grossPay=0
double grossPay=0;
//Set tax =0
double tax=0;
//Set netPay=0
double netPay=0;
//Create an instance of Scanner class
Scanner inputScanner =new Scanner(System.in);
System.out.println(\"Enter hourly rate of pay\");
//prompt for hourly rate
hourlyRate=Integer.parseInt(inputScanner.nextLine());
System.out.println(\"Enter number of hours worked\");
//prompt for number of hours
hoursWorked=Integer.parseInt(inputScanner.nextLine());
//Calculate grossPay
//multiply hoursWorked by hourlyRate
grossPay=hoursWorked*hourlyRate;
//calculate with hold tax
tax=grossPay*WITH_HOLD_TAX;
//calculate netPay
//subtract tax from grossPay
netPay=grossPay-tax;
//print gross pay and net pay to console
System.out.println(\"Gross Pay : \"+grossPay);
System.out.println(\"Net pay : \"+netPay);
}
}
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
Sample output:
Enter hourly rate of pay
10
Enter number of hours worked
50
Gross Pay : 500.0
Net pay : 425.0
Solution
/**
* The java Payroll that prompts user to enter
* hourly rate of pay and number of hours worked.
* Then calculates the gross pay and net pay
* and print to console.
* */
//Payroll.java
import java.util.Scanner;
public class Payroll
{
public static void main(String[] args)
{
//declare variables for hourly rate and hours worked
double hourlyRate;
int hoursWorked;
//Set tax rate as 0.15 (15 percent )
final double WITH_HOLD_TAX=0.15;
//Set grossPay=0
double grossPay=0;
//Set tax =0
double tax=0;
//Set netPay=0
double netPay=0;
//Create an instance of Scanner class
Scanner inputScanner =new Scanner(System.in);
System.out.println(\"Enter hourly rate of pay\");
//prompt for hourly rate
hourlyRate=Integer.parseInt(inputScanner.nextLine());
System.out.println(\"Enter number of hours worked\");
//prompt for number of hours
hoursWorked=Integer.parseInt(inputScanner.nextLine());
//Calculate grossPay
//multiply hoursWorked by hourlyRate
grossPay=hoursWorked*hourlyRate;
//calculate with hold tax
tax=grossPay*WITH_HOLD_TAX;
//calculate netPay
//subtract tax from grossPay
netPay=grossPay-tax;
//print gross pay and net pay to console
System.out.println(\"Gross Pay : \"+grossPay);
System.out.println(\"Net pay : \"+netPay);
}
}
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
Sample output:
E.
Banks offer various types of accounts, such as savings, checking, cer.pdfrajeshjain2109
Banks offer various types of accounts, such as savings, checking, certificate of deposits, and
money market, to attract customers as well as meet their specific needs. Two of the most
commonly used accounts are savings and checking. Each of these accounts has various options.
For example, you may have a savings account that requires no minimum balance but has a lower
interest rate. Similarly, you may have a checking account that limits the number of checks you
may write. Another type of account that is used to save money for the long term is certificate of
deposit (CD). In this programming exercise, you use abstract classes and pure virtual functions to
design classes to manipulate various types of accounts. For simplicity assume that the bank
offers three types of accounts: savings, checking, and certificate of deposit, as described next.
Savings accounts: Suppose that the bank offers two types of savings accounts: one that has no
minimum balance and a lower interest rate and another that requires a minimum balance and has
a higher interest rate Checking accounts: Suppose that the bank offers three types of checking
accounts: one with a monthly service charge, limited check writing, no minimum balance, and no
interest, another with no monthly service charge, a minimum balance requirement, unlimited
check writing and lower interest, and a third with no monthly service charge, a higher minimum
requirement, a higher interest rate, and unlimited check writing Certificate of deposit (CD): In an
account of this type, money is left for some time, and these accounts draw higher interest rates
than savings or checking accounts. Suppose that you purchase a CD for six months. Then we say
that the CD will mature in six months. The penalty
Solution
#include
#include
using namespace std;
class bankAccount
{
private:
string accHolderName;
string accountType;
int accountNumber;
double accBalance;
public:
bankAccount(string fullName = \"\", string accType = \"\", int accNum = 0, double balance =
0.0);
string getAccHolderName() const;
string getAccountType() const;
int getAccountNumber() const;
double getAccBalance() const;
void deposit(double amount);
void withdrawl(double amount);
virtual void print() const = 0;
};
/*contructor*/
bankAccount::bankAccount(string fullName, string accType, int accNum, double balance) {
accHolderName = fullName;
accountType = accType;
accountNumber = accNum;
accBalance = balance;
}
string bankAccount::getAccHolderName() const{
return accHolderName;
}
string bankAccount::getAccountType() const{
return accountType;
}
int bankAccount::getAccountNumber() const{
return accountNumber;
}
double bankAccount::getAccBalance() const{
return accBalance;
}
void bankAccount::deposit(double amount) {
accBalance += amount;
}
void bankAccount::withdrawl(double amount) {
if (amount > accBalance) {
cout << \"Insufficent Funds. Account balance: \" << accBalance << endl;
} else {
accBalance -= amount;
}
}
class checkingAccount: public bankAccount
{.
Create a new Java project and add the Account class into the source co.pdfadmin618513
Create a new Java project and add the Account class into the source code.
Create a JUnit test class, AccountTest , and write test cases which exercise all the methods of the
Account class.
Compile your classes and run the JUnit tests.
If your tests reveal any defects in the logic of the Account class, report them.
here are account.java file
import java.text.NumberFormat;
/**
* Account is a bank account with basic services for deposit,
* withdrawal, and interest.
*/
public class Account
{
private NumberFormat fmt = NumberFormat.getCurrencyInstance();
private final float kInterestRate = 0.045f; // interest rate of 4.5%
private long acctNumber;
private float balance;
public final String name;
/**
* Sets up the account by defining its owner, account number,
* and initial balance.
* @param owner name of account holder
* @param account the account number, an identifier for the account
* @param initial the initial amount of money in the account.
*/
public Account(String owner, long account, float initial)
{
name = owner;
acctNumber = account;
balance = initial;
}
/**
* Deposit the specified amount into the account.
* @param amount value to be added to the balance
* @return true if amount is non-negative, false if amount
* is negative; indicates balance was not changed.
*/
public boolean deposit(float amount)
{
boolean result = true;
// is amount invalid?
if (amount < 0)
{
result = false;
}
else
{
balance = balance + amount;
}
return result;
}
/**
* Withdraw the specified amount from the account,
* unless amount is negative, fee is negative, or
* amount exceeds current balance.
* @param amount value to be deducted from the balance
* @param fee the transaction fee debited from the account
* @return true if transaction was successful, false otherwise;
*/
public boolean withdraw(float amount, float fee)
{
// validate parameters
if (isValidWithdrawl(amount, fee))
{
amount += fee;
balance = balance - amount;
}
return isValidWithdrawl(amount, fee);
}
/* Determine if withdrawal parameters are valid */
private boolean isValidWithdrawl(float amount, float fee)
{
return amount >= 0 && fee >= 0 && amount <= balance;
}
/**
* Adds interest to the account.
*/
public void addInterest()
{
balance += (balance * kInterestRate);
}
/**
* Accessor to the current balance of the account.
* @return the current balance of the account.
*/
public float getBalance()
{
return balance;
}
/**
* Accessor to the account number.
* @return the account number.
*/
public long getAccountNumber()
{
return acctNumber;
}
/**
* Returns a one-line description of the account as a string.
* @return formatted account information
*/
public String toString()
{
return (acctNumber + "\t" + name + "\t" + fmt.format(balance));
}
}.
Please distinguish between the .h and .cpp file, create a fully work.pdfneerajsachdeva33
Please distinguish between the .h and .cpp file, create a fully working c++ program using the
diagram provided.
Section 1: Homework Objectives
1. Given a class UML, learn to write a C++ class declaration.
2. Learn how to define/call constructor, accessor, mutator or toString( )
Section 2: Background
In this homework, according to the given UML class diagram, you’re required to design a
BankAccount class. You are also required to write a driver’s program to test it.
Section 3: Program description
3.1 Introduction
According to the following UML diagram, design a BankAccount class.
BankAccount
-id: string = \"?\"
-balance: double = 0.0
-address: string = \"?\"
+BankAccount()
+BankAccount(string, double, string)
+getID(): string
+getBalance(): double
+getAddress(): string
+setID(string): void
+deposit(double): bool
+withdraw(double): bool
+updateAddress(string):void
+toString(): string
+addInterest(): void
+equals(BankAccount): bool
Member variables and member functions\' description
Member
Variable
Data Type
Description
id
string
This represents a bank account\'s unique ID, such as \"123-456-
789\"
balance
double
This is the account balance.
address
string
This represents a bank account customer\'s mailing address, such as \"12345 Via Linda Rd.
Phoenix, AZ 85048\"
Member Function
Function Description
BankAccount()
This is the default constructor and it should initialize all member varible by the initial value
defined inside the UML. For example, id should be initialized to \"?\" etc.
BankAccount(string newID, double newBal, string newAddress)
This is the overloadded constructor. It takes three input parameters and initialize the three
member variables accordingly with the three input parameters.
string getID()
This is the accessor for member variable id
double getBalance()
This is the accessor for member variable balance
string getAddress()
This is the accessor for member variable address
void setID(string newID)
This is the mutator for member variable id. It takes a new id as input and change the member
variable id accordingly
bool deposit(double amount)
This is a mutator for member variable balance. It takes an amount as input parameter, if the
amount of deposit is negative, the balance will not be changed and the function should return
false; otherwise, the deposited amount (parameter value) will be added to the balance and the
function returns true.
bool withdraw(double amount)
This is a mutator for member variable balance. It takes an amount as input parameter, if the
balance is less than the withdraw amount (parameter value) or the withdraw amount is less than
zero, the function should return false, otherwise subtract the balance by withdraw amount and
return true.
void updateAddress(string newAddress)
This is a mutator for member variable address. In case the bank account\'s customer want to
change his/her address, we will use this function.
string toString()
The toString function will display an bank account info. in the following format.
The complexity of frontend applications over the years led to the creation of more robust solutions, where data logic won’t be messed up at scale. A shift took place from the traditional services approach, in which data is tightly coupled to the Views of their Components, towards more composable and shareable solutions. Each of these solutions is what we call a "state-manager".
Goal of this presentation is the comparative analysis between different react frontend state managers such as Redux, MobX, Recoil and React-Query. State Machines will also be presented, showing a completely different perception of how state can be orchestrated. Different mental models of the aforementioned state managers along with their different technical implementations will be presented to the audience. Ultimately, the audience can use this presentation for future reference on faster deciding which state-manager fits their own projects. Before delving into the comparison there will be a description of the main data flow in the browser. Concepts like reactivity, immutability, predictability, concurrency and performance will be detected on the main flow and will act as our comparison metrics among the state-managers.
This is Due to highest Cncentration of Comon Ions.pdfannaindustries
This is Due to highest Cncentration of Comon Ions(SO42-) The reason is
\"Common Ion Effect\" (NH4)2SO4 has highest concentration of SO42-
Solution
This is Due to highest Cncentration of Comon Ions(SO42-) The reason is
\"Common Ion Effect\" (NH4)2SO4 has highest concentration of SO42-.
There is no reaction. The nearest I can think of .pdfannaindustries
There is no reaction. The nearest I can think of involving the above is: MgCl2 + 2
NaOH = Mg(OH)2 + 2 NaCl
Solution
There is no reaction. The nearest I can think of involving the above is: MgCl2 + 2
NaOH = Mg(OH)2 + 2 NaCl.
The decomposition of hydrogen peroxide to gaseous.pdfannaindustries
The decomposition of hydrogen peroxide to gaseous O2 and water is a spontaneous
process only means H2O2 is thermodynamically unstable. The fact that H2O2 is stable for long
periods of time indicates that H2O2 is kinetically stable. Thus. Adding catalyst will speed the
decomposition reaction up cause it decreases the activation energy.
Solution
The decomposition of hydrogen peroxide to gaseous O2 and water is a spontaneous
process only means H2O2 is thermodynamically unstable. The fact that H2O2 is stable for long
periods of time indicates that H2O2 is kinetically stable. Thus. Adding catalyst will speed the
decomposition reaction up cause it decreases the activation energy..
Im not entirely sure what this is asking. I ass.pdfannaindustries
I\'m not entirely sure what this is asking. I assume these are two processes being
performed on the molecule shown. I\'ve seen similar reactions and not exactly the same thing.
OsO4 usually adds OH cis if I recall to the inner carbons, but the OH groups are already there.
The second part of that might add SO2? For question 2 I\'m almost certain that the initial reaction
removes the OH groups on the original molecule and makes it into an epoxide. adding hydroxide
and H20 would make it a basic environment so an H+ in solution would protonate the epoxide.
OH would attach wherever the bond to the protonated epoxide was weakest, resulting in the
initial molecule with one of the centers having inverted stereochemistry 40% sure on all of this at
best. I just had my orgo final. good luck on yours :)
Solution
I\'m not entirely sure what this is asking. I assume these are two processes being
performed on the molecule shown. I\'ve seen similar reactions and not exactly the same thing.
OsO4 usually adds OH cis if I recall to the inner carbons, but the OH groups are already there.
The second part of that might add SO2? For question 2 I\'m almost certain that the initial reaction
removes the OH groups on the original molecule and makes it into an epoxide. adding hydroxide
and H20 would make it a basic environment so an H+ in solution would protonate the epoxide.
OH would attach wherever the bond to the protonated epoxide was weakest, resulting in the
initial molecule with one of the centers having inverted stereochemistry 40% sure on all of this at
best. I just had my orgo final. good luck on yours :).
First remember that non polar compounds are solub.pdfannaindustries
First remember that non polar compounds are soluble in non polar solvents (like
benzene in acetone) and polar compounds are soluble in polar solvents (like NaCl in H2O) Now
if you consider solubility in water, all polar compounds are soluble and the structure which can
make hydrogen bonding with water is also soluble like methanol which can form hydrogen
bonding with water.. First look at the structure to identify what kind of bonds are existing, if you
see any ionic bond it will be soluble in water. inorganic base is something like NaOH which has
the basic unit OH- which can easily take a proton from an organic acid and from a bond and
hence it will be soluble. organic base is soluble when organic acid is present because acid and
base has the larger tendency to get interacted and form a complex.
Solution
First remember that non polar compounds are soluble in non polar solvents (like
benzene in acetone) and polar compounds are soluble in polar solvents (like NaCl in H2O) Now
if you consider solubility in water, all polar compounds are soluble and the structure which can
make hydrogen bonding with water is also soluble like methanol which can form hydrogen
bonding with water.. First look at the structure to identify what kind of bonds are existing, if you
see any ionic bond it will be soluble in water. inorganic base is something like NaOH which has
the basic unit OH- which can easily take a proton from an organic acid and from a bond and
hence it will be soluble. organic base is soluble when organic acid is present because acid and
base has the larger tendency to get interacted and form a complex..
There are many types of malwares like Trojans, viruses, worms, rootk.pdfannaindustries
There are many types of malwares like Trojans, viruses, worms, rootkits, and many more
We will here discuss about viruses and worms
Viruses are the programs that gets themselves replicated itself and gets into other files and
programs and destroys data or makes the file damaged so that the file becomes corrupt or
damaged. Whenever the user tries to open the infected files virus gets spread in other files.
Worms are self-activated programs. They spreads over the networks and infect the other
computers in the network without user’s knowledge and permission and sends the data of one
system to others.
Solution
There are many types of malwares like Trojans, viruses, worms, rootkits, and many more
We will here discuss about viruses and worms
Viruses are the programs that gets themselves replicated itself and gets into other files and
programs and destroys data or makes the file damaged so that the file becomes corrupt or
damaged. Whenever the user tries to open the infected files virus gets spread in other files.
Worms are self-activated programs. They spreads over the networks and infect the other
computers in the network without user’s knowledge and permission and sends the data of one
system to others..
The standard form of a complex number is a real number plusminus an.pdfannaindustries
The standard form of a complex number is a real number plus/minus an imaginary number.
Divide each term in the numerator by the denominator.
(10 + i) / 14i =
(5/7)i + (1/14) = (1/14) (5/7)i
1/14 is the real part.
(5/7)i is the imaginary part.
Solution
The standard form of a complex number is a real number plus/minus an imaginary number.
Divide each term in the numerator by the denominator.
(10 + i) / 14i =
(5/7)i + (1/14) = (1/14) (5/7)i
1/14 is the real part.
(5/7)i is the imaginary part..
Question) one or more attributes that comprise a primary key in a ro.pdfannaindustries
Question) one or more attributes that comprise a primary key in a row in a relational table
Answer ) Key attribute
Entity Integrity
Foreign Key
Composite key
Key Attribute : represents primary key. (main characteristics of an entity). It is an attribute, that
has distinct value for each entity/element in an entity set. For example, Roll number in a Student
Entity Type.
Solution
Question) one or more attributes that comprise a primary key in a row in a relational table
Answer ) Key attribute
Entity Integrity
Foreign Key
Composite key
Key Attribute : represents primary key. (main characteristics of an entity). It is an attribute, that
has distinct value for each entity/element in an entity set. For example, Roll number in a Student
Entity Type..
Photosynthesis - is the unique process that is limited to plant king.pdfannaindustries
Photosynthesis - is the unique process that is limited to plant kingdom.Green plants are able to
synthesize carbohydrates in there systems due to the presence of an uinique structure called
chloroplast.
The chloroplasts are present only in plant kingdom which gives them the ability to trap solar
energy convert it into chemical energy along with the synthesis of carbohydrates and evolution
of oxygen, so the process of photosynthesis does not only fix the carbon di oxide but in the
process also give out oxygen.
These chloroplasts are present in diverse groups of plant kingdom and may show structural
differences . Though they exhibit variations in their structure they perform the same function.The
chloroplasts are membrane bound organnels locate din the cytoplasm and are responsible for the
trapping of solar energy and converting it into chemical energy in the form of ATP and
NADPH due to the presence of the pigment chlorophyll and in the process liberate oxygen from
the water molecule through a series of reactions.
The number of chloroplasts per cell vary from one organism to the other they may be varying
from 1 as seen in algae or may be upto 100 per cell as seen in higher plants.the chloroplasts
develop from a pre existing plastids known as the proplastid.whcih can develop into a variety of
plastids like the chloroplast, leucoplast amyloplast etc.
They are considered to have originated from cyanobacteria through endosymbiosis .The
ancestors of chloroplasts are believed to be the cyanobacteria or the blue-green algae .They are
often found as symbionts with a number of other groups of organisms like the
fungi,pteridophytes angiosperms .The oxygen present in the atmosphere is attributed due to the
activity of these cyanobacteria.They do not have a nucleus or any membrane bound organnels .
The photosynthetic apparatus is embedded into folds of the external cell membrane, called
thylakoids and contain a bluish green pigment phycocyanin and chlorophyll a.
The green algae cor the chlorophytes have a definite chloroplast whose shape may vary among
different members it may be cup shaped as seen in simple chlamydomonas , ribbon like as in
spirogyra or disc like as in higher members of the group . The main pigments are chlorophyll a, b
along with carotenoids and xanthophylls and have starch as the storage product.
the members of red algae have additional pigments in there chloroplast like phycobilins and
phycocyanins in addition to chlorophyll and the starch they make is also called as floridean
starch unique to the group.The brown algae differ from the other groups due to the presence of
the pigment fucoxanthin along with chlorophyll a and c which gives them the color.
If we move to higher group of plants like the bryophytes , Pteriodophytes, Gymnosperms and the
Angiosperms the chloroplast represents a well organized double membrane structures with they
thylakoids, grana , stroma , intergaranal lamella , stromal lamella and have chlorophyll as the
main.
Please follow the code and comments for description a)CODE #.pdfannaindustries
Please follow the code and comments for description :
a)
CODE :
#include // header file
using namespace std;
double factorial(double n); // required method with the double value
int main() // main method
{
int n;
cout << \"Enter a positive integer: \"; // prompt to get the integer value
cin >> n;
cout << \"Factorial of \" << n << \" = \" << factorial(n); // calluing the function
return 0;
}
double factorial(double n)
{
if(n!=1)
return n*factorial(n-1); // returning the result
}
OUTPUT :
Enter a positive integer: 6
Factorial of 6 = 720
b)
CODE :
#include // header file
#include
using namespace std;
int main() // main method
{
int count = 0; // required initialisations
string line;
ifstream file(\"input.txt\"); //Creating input filestream
while (getline(file, line)){ // iterating over the loop to get the data and count
count++;
cout << line << endl; // printing the data
}
cout << \"Numbers of lines in the file : \" << count << endl; // print the count
return 0;
}
input.txt :
Hi
Hello
How are You
Hope Your are Doing Good
See You
Tomorrow
Good Bye
Meet
You
LAter
OUTPUT :
Hi
Hello
How are You
Hope Your are Doing Good
See You
Tomorrow
Good Bye
Meet
You
LAter
Numbers of lines in the file : 10
Hope this is helpful.
Solution
Please follow the code and comments for description :
a)
CODE :
#include // header file
using namespace std;
double factorial(double n); // required method with the double value
int main() // main method
{
int n;
cout << \"Enter a positive integer: \"; // prompt to get the integer value
cin >> n;
cout << \"Factorial of \" << n << \" = \" << factorial(n); // calluing the function
return 0;
}
double factorial(double n)
{
if(n!=1)
return n*factorial(n-1); // returning the result
}
OUTPUT :
Enter a positive integer: 6
Factorial of 6 = 720
b)
CODE :
#include // header file
#include
using namespace std;
int main() // main method
{
int count = 0; // required initialisations
string line;
ifstream file(\"input.txt\"); //Creating input filestream
while (getline(file, line)){ // iterating over the loop to get the data and count
count++;
cout << line << endl; // printing the data
}
cout << \"Numbers of lines in the file : \" << count << endl; // print the count
return 0;
}
input.txt :
Hi
Hello
How are You
Hope Your are Doing Good
See You
Tomorrow
Good Bye
Meet
You
LAter
OUTPUT :
Hi
Hello
How are You
Hope Your are Doing Good
See You
Tomorrow
Good Bye
Meet
You
LAter
Numbers of lines in the file : 10
Hope this is helpful..
Optimized Waterfall processIs a common project methodology and it.pdfannaindustries
Optimized Waterfall process:
Is a common project methodology and it is a sequential design project method that was originally
consider for software development but is now used for a diversity of project types. It is generally
having 6 phases
1. Necessities
2. Design
3. Execution
4. Verification
5. Deployment
6. Preservation
Payoffs of water fall process:
There are several payoff of water fall process as follows
a). proper for simple or smaller projects
b). Requirements are well understood
c). Easy to understand
d). Easy to manage
e). Clear milestones
f). general documentation
Pitfalls of water fall process:
a). does not allow scope changes.
b). does not allow for requirement changes.
c). No working product until near completion of project.
Solution
Optimized Waterfall process:
Is a common project methodology and it is a sequential design project method that was originally
consider for software development but is now used for a diversity of project types. It is generally
having 6 phases
1. Necessities
2. Design
3. Execution
4. Verification
5. Deployment
6. Preservation
Payoffs of water fall process:
There are several payoff of water fall process as follows
a). proper for simple or smaller projects
b). Requirements are well understood
c). Easy to understand
d). Easy to manage
e). Clear milestones
f). general documentation
Pitfalls of water fall process:
a). does not allow scope changes.
b). does not allow for requirement changes.
c). No working product until near completion of project..
Organism Entameoeba histolyticQ AIt can be analyzed by feces te.pdfannaindustries
Organism :Entameoeba histolytic
Q A
It can be analyzed by feces tests, however take note of that specific different species are difficult
to recognize by microscopy alone. Trophozoites might be found in a new fecal spread and sores
in a standard feces test. ELISA or RIA can likewise be utilized
Q B
The dynamic (trophozoite) arrange exists just in the host and in crisp free defecation; growths
make due outside the host in water, in soils, and on sustenances, particularly under wet
conditions on the last mentioned.
Q C
Distinctive monophasic media that were created for E. histolytica are the egg yolk imbuement
medium of Balamuth , Jones\' medium , and TYSGM-9 . Of the diverse media created for the
xenic development of E. histolytica, just three media, diphasic Locke-egg, Robinson\'s medium
Q D
anaerobic
QE
Microscopy utilized in an indicative clinical research facility incorporate wet planning, fixation,
and for all time recolored smears for the distinguishing proof of E. histolytica/E. dispar/E.
moshkovskii in excrement. Tiny examination of an immediate saline (wet) mount is an
exceptionally uncaring strategy (<10%) which is performed on a crisp example .The example
ought to be analyzed inside 1 h of accumulation to hunt down motile trophozoites which may
contain RBCs. Be that as it may, in patients who don\'t present with intense looseness of the
bowels, trophozoites won\'t contain RBCs. Patients with asymptomatic carriage by and large
have just growths in the fecal example. In spite of the fact that the focus procedure is useful in
exhibiting sores, the utilization of forever recolored smears (trichrome or press hematoxylin) is
an imperative technique for recuperation and distinguishing proof of Entamoeba species.
Q F Q G
In most by far of cases, disease is asymptomatic and the bearer is uninformed they are tainted.
Be that as it may, in an expected 10% of cases E. histolytica causes ailment. Once the
trophozoites are excysted they colonize the extensive gut, staying on the surface of the bodily
fluid layer and sustaining on microscopic organisms and sustenance particles. Every so often,
and in light of obscure boosts, trophozoites travel through the bodily fluid layer where they
interact with the epithelial cell layer and begin the obsessive procedure. E. histolytica has a lectin
that ties to galactose and N-acetylgalactosamine sugars on the surface of the epithelial cells, The
lectin typically is utilized to tie microscopic organisms for ingestion. The parasite has a few
catalysts, for example, pore shaping proteins, lipases, and cysteine proteases, which are regularly
used to process microbes in nourishment vacuoles yet which can bring about lysis of the
epithelial cells by instigating cell putrefaction and apoptosis when the trophozoite interacts with
them and ties through the lectin. The trophozoites will then ingest these dead cells. This harm to
the epithelial cell layer draws in human resistant cells and these thusly can be lysed by .
Biological screening of herbal drugs: Introduction and Need for
Phyto-Pharmacological Screening, New Strategies for evaluating
Natural Products, In vitro evaluation techniques for Antioxidants, Antimicrobial and Anticancer drugs. In vivo evaluation techniques
for Anti-inflammatory, Antiulcer, Anticancer, Wound healing, Antidiabetic, Hepatoprotective, Cardio protective, Diuretics and
Antifertility, Toxicity studies as per OECD guidelines
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
Macroeconomics- Movie Location
This will be used as part of your Personal Professional Portfolio once graded.
Objective:
Prepare a presentation or a paper using research, basic comparative analysis, data organization and application of economic information. You will make an informed assessment of an economic climate outside of the United States to accomplish an entertainment industry objective.
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
Francesca Gottschalk - How can education support child empowerment.pptx
Hi,I have updated the code as per your requirement. Highlighted th.pdf
1. Hi,
I have updated the code as per your requirement. Highlighted the code changes below.
Program2.java
import java.util.Scanner; // Needed for the Scanner class
import java.text.DecimalFormat; // Needed for 2 decimal place amounts
public class Program2
{
public static void main(String[] args)
{
BankAccount account; // To reference a BankAccount object
double balance, // The account's starting balance
interestRate, // The annual interest rate
pay, // The user's pay
cashNeeded; // The amount of cash to withdraw
// Create a Scanner object for keyboard input.
Scanner keyboard = new Scanner(System.in);
// Create an object for dollars and cents
DecimalFormat formatter = new DecimalFormat ("#0.00");
// Get the starting balance.
System.out.print("What is your account's " + "starting balance? ");
balance = keyboard.nextDouble();
// Get the monthly interest rate.
System.out.print("What is your an annual interest rate? ");
interestRate = keyboard.nextDouble();
// Create a BankAccount object.
account = new BankAccount(balance, interestRate);
// Get the amount of pay for the month.
System.out.print("How much were you paid this month? ");
pay = keyboard.nextDouble();
// Deposit the user's pay into the account.
System.out.println("We will deposit your pay " + "into your account.");
account.deposit(pay);
System.out.println("Your current balance is " + formatter.format( account.getBalance() ));
// Withdraw some cash from the account.
System.out.print("How much would you like " + "to withdraw? ");
2. cashNeeded = keyboard.nextDouble();
account.withdraw(cashNeeded);
// Add the monthly interest to the account.
account.addInterest();
// Display the interest earned and the balance.
System.out.println("This month you have earned " + formatter.format( account.getInterest() ) +
" in interest.");
System.out.println("Now your balance is "+ formatter.format( account.getBalance() ) );
}
}
BankAccount.java
public class BankAccount
{
private double balance; // Account balance
private double interestRate; // Interest rate
private double interest; // Interest earned
/**
* The constructor initializes the balance
* and interestRate fields with the values
* passed to startBalance and intRate. The
* interest field is assigned to 0.0.
*/
public BankAccount(double startBalance, double intRate)
{
balance = startBalance;
interestRate = intRate / (12 * 100);
interest = 0.0;
}
/**
* The deposit method adds the parameter
* amount to the balance field.
*/
public void deposit(double amount)
{
balance += amount;
3. }
/**
* The withdraw method subtracts the
* parameter amount from the balance
* field.
*/
public void withdraw(double amount)
{
balance -= amount;
}
/**
* The addInterest method adds the interest
* for the month to the balance field.
*/
public void addInterest()
{
interest = balance * interestRate;
balance += interest;
}
/**
* The getBalance method returns the
* value in the balance field.
*/
public double getBalance()
{
return balance;
}
/**
* The getInterest method returns the
* value in the interest field.
*/
public double getInterest()
{
return interest;
}
}
4. Output:
What is your account's starting balance? 500
What is your an annual interest rate?
1.5
How much were you paid this month? 1000
We will deposit your pay into your account.
Your current balance is 1500.00
How much would you like to withdraw? 900
This month you have earned 0.75 in interest.
Now your balance is 600.75
Solution
Hi,
I have updated the code as per your requirement. Highlighted the code changes below.
Program2.java
import java.util.Scanner; // Needed for the Scanner class
import java.text.DecimalFormat; // Needed for 2 decimal place amounts
public class Program2
{
public static void main(String[] args)
{
BankAccount account; // To reference a BankAccount object
double balance, // The account's starting balance
interestRate, // The annual interest rate
pay, // The user's pay
cashNeeded; // The amount of cash to withdraw
// Create a Scanner object for keyboard input.
Scanner keyboard = new Scanner(System.in);
// Create an object for dollars and cents
DecimalFormat formatter = new DecimalFormat ("#0.00");
// Get the starting balance.
System.out.print("What is your account's " + "starting balance? ");
balance = keyboard.nextDouble();
// Get the monthly interest rate.
System.out.print("What is your an annual interest rate? ");
5. interestRate = keyboard.nextDouble();
// Create a BankAccount object.
account = new BankAccount(balance, interestRate);
// Get the amount of pay for the month.
System.out.print("How much were you paid this month? ");
pay = keyboard.nextDouble();
// Deposit the user's pay into the account.
System.out.println("We will deposit your pay " + "into your account.");
account.deposit(pay);
System.out.println("Your current balance is " + formatter.format( account.getBalance() ));
// Withdraw some cash from the account.
System.out.print("How much would you like " + "to withdraw? ");
cashNeeded = keyboard.nextDouble();
account.withdraw(cashNeeded);
// Add the monthly interest to the account.
account.addInterest();
// Display the interest earned and the balance.
System.out.println("This month you have earned " + formatter.format( account.getInterest() ) +
" in interest.");
System.out.println("Now your balance is "+ formatter.format( account.getBalance() ) );
}
}
BankAccount.java
public class BankAccount
{
private double balance; // Account balance
private double interestRate; // Interest rate
private double interest; // Interest earned
/**
* The constructor initializes the balance
* and interestRate fields with the values
* passed to startBalance and intRate. The
* interest field is assigned to 0.0.
*/
public BankAccount(double startBalance, double intRate)
6. {
balance = startBalance;
interestRate = intRate / (12 * 100);
interest = 0.0;
}
/**
* The deposit method adds the parameter
* amount to the balance field.
*/
public void deposit(double amount)
{
balance += amount;
}
/**
* The withdraw method subtracts the
* parameter amount from the balance
* field.
*/
public void withdraw(double amount)
{
balance -= amount;
}
/**
* The addInterest method adds the interest
* for the month to the balance field.
*/
public void addInterest()
{
interest = balance * interestRate;
balance += interest;
}
/**
* The getBalance method returns the
* value in the balance field.
*/
public double getBalance()
7. {
return balance;
}
/**
* The getInterest method returns the
* value in the interest field.
*/
public double getInterest()
{
return interest;
}
}
Output:
What is your account's starting balance? 500
What is your an annual interest rate?
1.5
How much were you paid this month? 1000
We will deposit your pay into your account.
Your current balance is 1500.00
How much would you like to withdraw? 900
This month you have earned 0.75 in interest.
Now your balance is 600.75