-1

重複の可能性:
スレッド「メイン」での例外 java.lang.UnsupportedClassVersionError: a (Unsupported major.minor version 51.0)

私は現在、ラボ課題の一部であるクラスに取り組んでいます。私がクラスを書き、教授がメインクラスを提供しました。彼女が Net Beans で提供した main.class を実行すると、次のエラーが表示されます。

java.lang.ClassLoader.loadClass(ClassLoader.java:247) の loadClass(Launcher.java:301) メイン クラスが見つかりませんでした: csit1520.lab1f.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 に答える