// CreditCard.java
import java.util.*;import javax.swing.JOptionPane;class CreditCustomer {
private String custName; // customer name
private String custAddress; // customer address
private String creditReport; // credit status private int accountNumber; // account number
private int credits; // total credits
private int creditLimit; // allowed credit limit
private int balance; // coutomer's balance CreditCustomer(String a,String b,String c){
custName=a;
custAddress=b;
creditReport=c; }/* write code to create default constructor, parameterized constructor */void getCustInfo(){
/* write the code for the method to accept customer information */ String inputString1 = JOptionPane.showInputDialog( "Enter account number: " );
String inputString2 = JOptionPane.showInputDialog( "Enter credits: " );
String inputString3 = JOptionPane.showInputDialog( "Enter credit Limit: " );
String inputString4 = JOptionPane.showInputDialog( "Enter balance: " );
/* write code to convert the input string to an integer
and store it in account */
accountNumber=Integer.parseInt(inputString1);
credits=Integer.parseInt(inputString2);
creditLimit=Integer.parseInt(inputString3);
balance=Integer.parseInt(inputString4);
/* write code to input the rest of the customer information and convert the
inputs to integers. Store each value in inputString before conversion. */
}
void showCustInfo(){
JOptionPane.showMessageDialog(null, "cust Name:"+custName+"\n cust Address: "+custAddress+"\n credit Report: "+creditReport);
/*write the code for the method to display customer information */}
void showBalance(){
if(credits>creditLimit){balance=1;
JOptionPane.showMessageDialog(null,"your creditCard is balanced");
}
else{ balance=0;
JOptionPane.showMessageDialog(null,"your creditCard no balance!");}
/* write code to compute the new balance */
}
boolean checkBalance(){
boolean a;
if(credits>creditLimit)a=true;
else a=false;
/* write code to check if customer has enough credit */
return a;
}
void purchase(){
int a;/* write code for customer to purchase */
Scanner reader=new Scanner(System.in);
JOptionPane.showMessageDialog(null,"The money need to purchase: ");
a=reader.nextInt();
if(a>credits-creditLimit){JOptionPane.showMessageDialog(null,"The money isn't enough.");}
else{
credits=credits-a;
JOptionPane.showMessageDialog(null,"purchase successfully.");
}/* create all the supporting method that you think is required to support this class */}}
public class CreditCard {
// main method begins execution of Java application
public static void main(String[] args) {
/* write code to create an object of CreditCustomer & perform transaction on the object */
CreditCustomer abc=new CreditCustomer("Jim","China","perfect");
System.exit( 0 );
}// end method main}// end class CreditCard以上是代码 请问有那些错误 请教高手
import java.util.*;import javax.swing.JOptionPane;class CreditCustomer {
private String custName; // customer name
private String custAddress; // customer address
private String creditReport; // credit status private int accountNumber; // account number
private int credits; // total credits
private int creditLimit; // allowed credit limit
private int balance; // coutomer's balance CreditCustomer(String a,String b,String c){
custName=a;
custAddress=b;
creditReport=c; }/* write code to create default constructor, parameterized constructor */void getCustInfo(){
/* write the code for the method to accept customer information */ String inputString1 = JOptionPane.showInputDialog( "Enter account number: " );
String inputString2 = JOptionPane.showInputDialog( "Enter credits: " );
String inputString3 = JOptionPane.showInputDialog( "Enter credit Limit: " );
String inputString4 = JOptionPane.showInputDialog( "Enter balance: " );
/* write code to convert the input string to an integer
and store it in account */
accountNumber=Integer.parseInt(inputString1);
credits=Integer.parseInt(inputString2);
creditLimit=Integer.parseInt(inputString3);
balance=Integer.parseInt(inputString4);
/* write code to input the rest of the customer information and convert the
inputs to integers. Store each value in inputString before conversion. */
}
void showCustInfo(){
JOptionPane.showMessageDialog(null, "cust Name:"+custName+"\n cust Address: "+custAddress+"\n credit Report: "+creditReport);
/*write the code for the method to display customer information */}
void showBalance(){
if(credits>creditLimit){balance=1;
JOptionPane.showMessageDialog(null,"your creditCard is balanced");
}
else{ balance=0;
JOptionPane.showMessageDialog(null,"your creditCard no balance!");}
/* write code to compute the new balance */
}
boolean checkBalance(){
boolean a;
if(credits>creditLimit)a=true;
else a=false;
/* write code to check if customer has enough credit */
return a;
}
void purchase(){
int a;/* write code for customer to purchase */
Scanner reader=new Scanner(System.in);
JOptionPane.showMessageDialog(null,"The money need to purchase: ");
a=reader.nextInt();
if(a>credits-creditLimit){JOptionPane.showMessageDialog(null,"The money isn't enough.");}
else{
credits=credits-a;
JOptionPane.showMessageDialog(null,"purchase successfully.");
}/* create all the supporting method that you think is required to support this class */}}
public class CreditCard {
// main method begins execution of Java application
public static void main(String[] args) {
/* write code to create an object of CreditCustomer & perform transaction on the object */
CreditCustomer abc=new CreditCustomer("Jim","China","perfect");
System.exit( 0 );
}// end method main}// end class CreditCard以上是代码 请问有那些错误 请教高手
// main method begins execution of Java application
public static void main(String[] args) {
/* write code to create an object of CreditCustomer & perform transaction on the object */
CreditCustomer abc=new CreditCustomer("Jim","China","perfect");
abc.getCustInfo();
abc.showCustInfo();
abc.checkBalance();
abc.showBalance();
abc.purchase();
System.exit( 0 );
}// end method main}// end class CreditCard
主类是这样的