急!这道题是什么个意思(JAVA) 现在学java的都是傻子
求解此Java题
public abstract class Account {
protected String name;
protected String aid;
protected double balance;
public Account(String name, String aid, double balance) {
this.name = name;
this.aid = aid;
this.balance = balance;
}
public void deposit(double amount) {
System.out.println(name + "您存入" + amount +"!");
this.balance+=amount;
}
public abstract void withdraw(double amount);
public double getBalance() {
return balance;
}
public String toString() {
return "姓名:" + name + "," + "帐号:" + aid + "," + "余额:" + balance;
}
}
public class BankApp {
public static void main(String[] args) {
// TODO Auto-generated method stub
CashAccount ca1=new CashAccount("张三","1001",5000,"工资卡");
CreditAccount ca2=new CreditAccount("李四","1002",7000,'B');
System.out.println(ca1.toString());
System.out.println(ca2.toString());
ca2.deposit(1000);
System.out.println(ca2.toString());
ca2.withdraw(3000);
System.out.println(ca2.toString());
ca2.withdraw(3000);
System.out.println(ca2.toString());
ca2.deposit(1000);
System.out.println(ca2.toString());
ca2.withdraw(3000);
System.out.println(ca2.toString());
ca2.withdraw(3000);
System.out.println(ca2.toString());
ca2.withdraw(3000);
System.out.println(ca2.toString());
}
}
public class CashAccount extends Account{
private String type;
public CashAccount(String name,String aid,double balance,String type)
{
super(name,aid,balance);
this.type=type;
}
@Override
public void withdraw(double amount) {
if(balance>=amount){
balance-=amount;
System.out.println("你取了"+amount);
return;
}
try{
if(balance<amount){
throw new WithdrawException(balance,"您的余额小于取款金额,不能取款!");
}
}catch(WithdrawException e){
System.out.println(e.toString());
return;
}
}
public String toString()
{
String str;
str=super.toString();
str+=",卡类型:"+type;
return str;
}
}
public class CreditAccount extends Account{
private char creditLevel;
private double lineOfCredit;
public CreditAccount(String name,String aid,double balance,char creditLevel)
{
super(name,aid,balance);
this.creditLevel=creditLevel;
calcLineOfCredit();
}
public void calcLineOfCredit()
{
switch(creditLevel)
{
case 'A':
lineOfCredit=10000;
break;
case 'B':
lineOfCredit=5000;
break;
case 'C':
lineOfCredit=2000;
break;
case 'D':
lineOfCredit=1000;
break;
}
}
public void withdraw(double amount) {
// TODO Auto-generated method stub
double temp=balance-amount;
if(temp>=0)
{
balance-=amount;
System.out.println("你没有透支,取了"+amount);
}
else
{
temp=-temp;
if(temp<=lineOfCredit)
{
System.out.println("你透支了,取了"+amount+",透支了"+temp);
balance-=amount;
}
try{
if(temp>lineOfCredit){
throw new WithdrawException(balance,"你的透支额度超过了信用额度,不能取钱!");
}
}catch(WithdrawException e){
System.out.println(e.toString());
return;
}
}
}
public String toString()
{
String str;
str=super.toString();
str+="," + "信用等级:"+ creditLevel+","+ "透支额度:" + lineOfCredit;
return str;
}
}
public class WithdrawException extends Exception{
double balance;
public WithdrawException(double balance,String message) {
super(message);
this.balance = balance;
}
public String toString()
{
String str;
str="你帐户的余额为:"+balance+" ";
str+=super.getMessage();
return str;
}
}
JAVA是什么意思
Java是由Sun微系统公司所发展出来的程序语言,它本身是一种对象导向(Object-Oriented)的程序语言。JAVA目前在手机上应用最多的就是JAVA游戏。 Java也号称是能跨平台使用的语言,这主要是因为Java本身被编译之后,并不是直接产生可执行的码,而是产生一种中间码叫作 ByteCode,这种码必需在透过 Java 的直译器来解读它,才能够真正的被执行,所以只要平台上装有这种Java的直译器,就能解读ByteCode也就能执行Java编译过的程序,故与Java程序是在那种平台上被编译的,就完全没有干系了。Java写出来的程序可分为两类,分别是Java Applet与一般的Application,而Application 这一类就与一般的程序如C++的作用是比较类似的,是一个独立可执行的应用程序,像HotJava是一个浏览器,且就是使用Java程序所发展出来的。最常见的Java程序包括应用程序和applets。应用程序是单独的程序,诸如HotJava浏览器软件就是用Java语言编写的。 Applets类似于应用程序,但是它们不能单独运行, Applets可以在支持Java的浏览器中运行。Applet主要是内置于HTML网页中,在浏览时发挥作用。 Java的目标是为了满足在一个充满各式各样不同种机器,不同操作系统平台的网络环境中开发软件。利用Java程序语言,可以在网页中加入各式各样的动态效果。可以放上一段动画,加入声音,也可以建立交互式网页等。
java编程简答题
public class student {
private string 学号;
private string 姓名;
private string 年龄;
private string 专业;
private string 年级;
public student(string 学号, string 姓名, string 年龄, string 专业, string 年级) {
this.学号 = 学号;
this.姓名 = 姓名;
this.年龄 = 年龄;
this.专业 = 专业;
this.年级 = 年级;
}
public void display() {
system.out.println("学号:"+学号+" 姓名:"+姓名+" 年龄:"+年龄+" 专业:"+专业+" 年级:"+年级);
}
public static void main(string[] args) {
student student = new student("学号", "姓名", "年龄", "专业", "年级");
student.display();
}
}
谁能帮我一步步的解释这java的题目
class Circle //定义类型叫Circle
{
final double PI=3.14; //定义一个double型的不可变常量PI 为3.14
private double radius; //定义一个double型的私有变量radius,保存半径长度
public void setRadius(double r) //定义一个方法,用来设置类的私有变量radius
{
radius=r; //用传进来的参数给半径设置
}
public double area()
{
double area;
area=PI*radius*radius; //求该圆的面积
return area; //返回面积的值
}
public static void main(String[] args)
{
Circle myCircle=new Circle(); //定义一个Circle对象
myCircle.setRadius(4.2); //给对象的半径设置成为4.2
System.out.println("the area of this circle is"+myCircle.area()); //打印出面积的信息
}
}