java程序求改正
classBankAccount{staticfinaldoubleLOWESTBALANCE=10.0;staticdoubleInterestRate;Stringn...
class BankAccount{
static final double LOWESTBALANCE=10.0;
static double InterestRate;
String name;
String Address;
private double balance;
public BankAccount(String mname,double intitbalance,String nAddress){
if(initbalance<LOWERSTBALANCE)
System.exit(0);
initbalance=balance;
name=new String(mname);
Address=newString(nAddress);
}
static boolean setInterestRate(double newRate)
{
if(newRate>0){
InterestRate=newRate;
return ture;
}
else{
return false;
}
}
double getBalance(){
return balance;
}
static doublr getInterestRate(){
return InteresetRate;
}
void setMoney(double saveAccount){
if(saveAccount>0){
balance+=saveAccount;
}}
boolean getMoney(double getamount){
if(balance-getamount>LOWESTBALANCE){
balance=getamount;
}
else{return false;
}
}
double calculateInterest(int Days){
return (balance*InterestRate*Days/365);
}
void accountInterest(int Days){
balance+=calculateInterest(Days);
}
}
String AccountMeg(){
String s="";
s="accountName:"+name+"\naccountBalance:"+Double.toString(balance)+"\nCurrent InterestRate:"+Double.toString(InterestRate)+"\nArress:"+Address;
return s;
}
public class SimpleAccount{
public static void main(String[] args){
double init_value=10.0;
double save_value=1000.0;
double get_value=100.0;
double interest_rate=0.3;
BankAccount ba=new BankAccount("zhangli",init_value,"二十七路66号");
ba.setmoney(save_value);
System.out.println(ba.AccountMeg());
for(int i=1;i<=10;i++){
ba.accountIntereset(365);
}
System.out.println("balance after 10 years:\t"+ba.getBalance());
}
} 展开
static final double LOWESTBALANCE=10.0;
static double InterestRate;
String name;
String Address;
private double balance;
public BankAccount(String mname,double intitbalance,String nAddress){
if(initbalance<LOWERSTBALANCE)
System.exit(0);
initbalance=balance;
name=new String(mname);
Address=newString(nAddress);
}
static boolean setInterestRate(double newRate)
{
if(newRate>0){
InterestRate=newRate;
return ture;
}
else{
return false;
}
}
double getBalance(){
return balance;
}
static doublr getInterestRate(){
return InteresetRate;
}
void setMoney(double saveAccount){
if(saveAccount>0){
balance+=saveAccount;
}}
boolean getMoney(double getamount){
if(balance-getamount>LOWESTBALANCE){
balance=getamount;
}
else{return false;
}
}
double calculateInterest(int Days){
return (balance*InterestRate*Days/365);
}
void accountInterest(int Days){
balance+=calculateInterest(Days);
}
}
String AccountMeg(){
String s="";
s="accountName:"+name+"\naccountBalance:"+Double.toString(balance)+"\nCurrent InterestRate:"+Double.toString(InterestRate)+"\nArress:"+Address;
return s;
}
public class SimpleAccount{
public static void main(String[] args){
double init_value=10.0;
double save_value=1000.0;
double get_value=100.0;
double interest_rate=0.3;
BankAccount ba=new BankAccount("zhangli",init_value,"二十七路66号");
ba.setmoney(save_value);
System.out.println(ba.AccountMeg());
for(int i=1;i<=10;i++){
ba.accountIntereset(365);
}
System.out.println("balance after 10 years:\t"+ba.getBalance());
}
} 展开
1个回答
展开全部
class BankAccount {
static final double LOWESTBALANCE = 10.0;
static double InterestRate;
String name;
String Address;
private double balance;
public BankAccount(String mname, double intitbalance, String nAddress) {
if (InterestRate < LOWESTBALANCE)
System.exit(0);
InterestRate = balance;
name = new String(mname);
Address = new String(nAddress);
}
static boolean setInterestRate(double newRate) {
if (newRate > 0) {
InterestRate = newRate;
return true;
} else {
return false;
}
}
double getBalance() {
return balance;
}
static double getInterestRate() {
return InterestRate;
}
void setMoney(double saveAccount) {
if (saveAccount > 0) {
balance += saveAccount;
}
}
boolean getMoney(double getamount) {
if (balance - getamount > LOWESTBALANCE) {
balance = getamount;
return true;
} else {
return false;
}
}
double calculateInterest(int Days) {
return (balance * InterestRate * Days / 365);
}
void accountInterest(int Days) {
balance += calculateInterest(Days);
}
String AccountMeg() {
String s = "";
s = "accountName:" + name + "\naccountBalance:"
+ Double.toString(balance) + "\nCurrent InterestRate:"
+ Double.toString(InterestRate) + "\nArress:" + Address;
return s;
}
}
public class Test {
public static void main(String[] args) {
double init_value = 10.0;
double save_value = 1000.0;
double get_value = 100.0;
double interest_rate = 0.3;
BankAccount ba = new BankAccount("zhangli", init_value, "二十七路66号");
ba.setMoney(save_value);
System.out.println(ba.AccountMeg());
for (int i = 1; i <= 10; i++) {
ba.accountInterest(365);
}
System.out.println("balance after 10 years:\t" + ba.getBalance());
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询