最后的代码如下所示。修正了错误,理解了继承的概念。感谢你们回复我的帖子。你的答复很有帮助。
帐户类别
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();
}
}
字符串应该有大写字母s。将string
更改为string
。字符串类名以“%s”开头
String accountTitle;
String accountNumber;
问题内容: 我的JDBC代码有问题。我正在尝试通过MySQL连接,但它给了我一个错误。如果您有时间,下面会给出我的错误日志。 我的代码如下。我正在使用驱动程序: 问题答案: 当您使用Eclipse作为IDE并尝试运行甚至无法编译的代码时,都会发生此错误。在Eclipse中检查“ 问题” 视图,并在执行应用程序之前修复编译错误。
错误页面截图。选择的文本就是错误。
我在导入类和设置变量时遇到了问题,我需要帮助我正在做的一个测试程序。所以我正在测试一个程序,它只是简单地输出您的输入并放置时间戳(如Skype)。我在使消息和时间变量类型工作时遇到了问题!这是我的代码: 这是我的错误:
这是我遇到的错误 这是我的代码。
我的JDBC代码有一些问题。我正在尝试通过MySQL连接,但它给我一个错误。如果您有时间,我的错误日志如下所示。 我的代码如下。我正在使用驱动程序:
“main”java.lang.error线程中的异常:未解决的编译问题:linearequationproblem无法解析为linearequationproblem无法解析为linearequationproblem无法解析为linearequationproblem.Main(LineArequationProblemRedo.java:86)中的类型“