-1

可能重复:
线程“主”java.lang.UnsupportedClassVersionError 中的异常:a(不支持 d major.minor 版本 51.0)

我目前正在上一门属于实验室作业的课程。我写了这门课,我的教授提供了主课。当我运行她在 Net Beans 中提供的 main.class 时,我收到以下错误:

loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) 找不到主类:csit1520.lab1f.Main。程序将会退出。线程“main”Java 结果中的异常:1 ____________________________________

我还附上了我的 CreditCard.class 和 main.class。任何帮助是极大的赞赏。我是编程新手,不知道我做错了什么。


THE MAIN CLASS
package csit.lab1f;
import java.util.Scanner;

 /**
 *
 */
 public class Main {
 public static void main(String a[] )
{
    Scanner input = new Scanner( System.in );
    double balance; // user entered

    // get first balance from user
    System.out.println( "Enter account balance(0 to end): ");
    balance = input.nextDouble();
    while ( balance != 0 )
   {
        // get a credit card with user entered balance
        CreditCard c = new CreditCard( balance );
        // calculate card's new interest, balance, min payment
        c.calculateStatement();
        // print card's statement
        c.printStatement();
        // get next balance
        System.out.println( "Enter account balance (0 to end): ");
        balance = input.nextDouble();
    }
}
} 

我的信用卡等级

package csit.lab1f;

/**
 *
 * 
 */
public class CreditCard {

  public final static double MINIMUM_PAYMENT_PERCENT = 0.1;
  public final static double HIGH_INTEREST_BORDER = 1000;
  public final static double HIGH_INTEREST = 0.015;
  public final static double LOW_INTEREST = 0.01;
  public final static double MINIMUM_PAYMENT = 10.0;    
  int nextAccountNumber = 12340000;

  private int accountID;
  private double previousBalance;
  private double interest;
  private double currentBalance = interest + previousBalance;
  private double minimumPayment;



  public CreditCard(){
  accountID = nextAccountNumber;
  nextAccountNumber++;
  previousBalance = 0;
  interest = 0;
  minimumPayment = 0;
  currentBalance = 0;}

  public CreditCard(double b){
  previousBalance = b;
  accountID = nextAccountNumber;
  nextAccountNumber++;
  interest = 0;
  minimumPayment = 0;
  currentBalance = 0;}

  public CreditCard(int a, double b){
  previousBalance = b;
  accountID = a;
  nextAccountNumber ++;
  interest = 0;
  minimumPayment = 0;
  currentBalance = 0;}      

  public void setInterest(double i){
  interest = i;}

  public double getInterest(){
  return interest;}

  public void setnextAccountNumber(int a){
  nextAccountNumber = a;}

  public int getnextAccountNumber(){
  return nextAccountNumber;}

  public void setaccountId(int acct){
  accountID = acct; }

  public int getaccountId(){
  return accountID;}

  public void setpreviousBalance(double p){
  previousBalance = p;}

  public double getpreviousBalance(){
  return previousBalance;}

  public void setminimumPayment(double pm){
  minimumPayment = pm;}

  public double getminimumPayment(){
  return minimumPayment;}

  public void setcurrentBalance(double cb){
  currentBalance = cb; }

  public double getcurrentBalance (){
  return currentBalance; }



  public void calculateStatement(){
  if (previousBalance <= 1000){
        interest = previousBalance* 0.015;}

  else { 
       interest = 15+(previousBalance - 1000)*0.01;}

  currentBalance = previousBalance + interest;

  if (currentBalance < 10){
        minimumPayment = currentBalance;}

  else  {minimumPayment = currentBalance * .10; }

  }

  public void printStatement(){

  String string1 = String.format ("Your old account balance  S%4.2f",previousBalance);      
  String string2 = String.format ("Your current interest $%3.2f",interest);
  String string3 = String.format ("Your new account balance $%3.2f",currentBalance);                  
  String string4 = String.format ("Your minimum payment $%4.2f",minimumPayment);                 


  System.out.println(string1);

  System.out.println(string2);

  System.out.println(string3);

  System.out.println(string4);
  }




 }
4

1 回答 1

4

如果您查看错误中的第一句,您可以看到您正在运行不受支持的类版本。只需更新java,你应该很高兴!

于 2012-09-09T21:29:27.907 回答