当前位置: 首页 > 知识库问答 >
问题:

线程“main”java.lang.error中的异常:未解决的编译问题(字符串)

太叔志尚
2023-03-14

最后的代码如下所示。修正了错误,理解了继承的概念。感谢你们回复我的帖子。你的答复很有帮助。

帐户类别

public class Account {
String name;
String number;
public double balance;


public class Account 
{
public String acctnum;
public String accttitle;
public Double acctbal;
public String accttitle2;
public Account()
{
}
public void withdraw(Double amount)
{
 acctbal=acctbal-amount;
}
public void deposit(Double amount)
{
  acctbal=acctbal+amount;    
}
public double zakat() /*In Islam Zakat is deducted every year from saving 
                        accounts in holy month of Ramadan  */
{
 Double z=acctbal*0.025;
 return z;
}
 public void showdetail()
{
 System.out.println("The Account Number  ="+acctnum);
 System.out.println("The Account Title   ="+accttitle);
 System.out.println("The Account Balance ="+acctbal);  
}
}
public class CurrentAccount extends Account
{   
  public CurrentAccount(String Num,String Title,double Bal)
{
 acctnum = Num;
 accttitle = Title;
 acctbal = Bal;
}
public double tax()
{
double t= acctbal*0.05;
return t;        
}
}
public class JointAccount extends Account
{
public String accttitle2;
public JointAccount(String Num,String Title,String accttitle_1,double Bal)
{
  acctnum = Num;
  accttitle=Title;
  accttitle2=accttitle_1;
  acctbal  =Bal;
}
 public void showdetail()  //Overrding
{
System.out.println("The Account Number  = " + acctnum);
System.out.println("The Account Title   = " + accttitle + " and " + accttitle2);
System.out.println("The Account Balance = " + acctbal);
}
public double calculatetax()
{
 double t= acctbal*0.09;
 return t;
}
}
public class savingAccount extends Account 
{
  public savingAccount(String Num,String Title,Double Bal)
{
  super.acctnum  =Num;
  super.accttitle=Title;
  super.acctbal  =Bal;
}
public double tax()
{
double t= acctbal*0.07;
return t;
}
public void withdraw(double amount)
{
   super.withdraw(amount);
     if(acctbal<1000){
     acctbal=acctbal-150;
 }
}
public class testApp 
{
public static void main(String args[])
{
savingAccount obj=new savingAccount("01-102-33","Ali",30000.0); 

System.out.println("My Balance is="+obj.acctbal);
obj.withdraw(5000.0);
System.out.println("After Withdraw The Balanc is="+obj.acctbal); 

obj.deposit(10000.0);
System.out.println("After deposit balance is  ="+obj.acctbal); 

double z= obj.zakat();
System.out.println("zakat is="+z); 

obj.withdraw(z);
System.out.println("after draw balance is="+obj.acctbal);

double t=obj.tax();
System.out.println("Tax is="+t);

obj.withdraw(t);
System.out.println("Remaining balance is ="+obj.acctbal);
obj.withdraw(25000.0);
obj.showdetail();

CurrentAccount obj1=new CurrentAccount("01-102-33","Ali",10000.0);
System.out.println("My Balance is="+obj1.acctbal);
t=obj1.tax();
System.out.println("Tax is ="+t);

obj1.withdraw(t);
System.out.println("Remaining bal is="+obj1.acctbal);

obj1.showdetail();

JointAccount obj2=  new JointAccount("11-101-23","Amjad","Usman",20000.0);

System.out.println("My Balance is="+obj2.acctbal);
t=obj2.calculatetax();
System.out.println("Tax is ="+t);
obj2.showdetail();
}
}

共有1个答案

乔伯寅
2023-03-14

字符串应该有大写字母s。将string更改为string字符串类名以“%s”开头

String accountTitle;
String accountNumber;
 类似资料: