该类型已在Java中定义错误

该类型已在Java中定义错误,java,eclipse,Java,Eclipse,我正在努力完成我的作业,我必须把所有答案汇总到一个“.java”文件中。但是当我试图将所有类添加到一个文件中时,我得到一个“类型que2已经为que2、3和4定义了””错误。为什么我会犯这个错误?但是如果我在单独的文件中运行它们,我可以毫无错误地运行它们。我已经习惯python了,我从来没有经历过这样的事情。谢谢你,祝你今天愉快。 顺便说一句,我正在使用eclipse /* *************************************************************

我正在努力完成我的作业,我必须把所有答案汇总到一个“.java”文件中。但是当我试图将所有类添加到一个文件中时,我得到一个“类型que2已经为que2、3和4定义了””错误。为什么我会犯这个错误?但是如果我在单独的文件中运行它们,我可以毫无错误地运行它们。我已经习惯python了,我从来没有经历过这样的事情。谢谢你,祝你今天愉快。 顺便说一句,我正在使用eclipse

/* *****************************************************************************
 *  Name:         Emre Cokcalışı
 *  Student ID:   6321211
 *  Department:   Industrial Engineering
 *
 *  Assignment ID: A1 Question 1 
 *
 *  Description:  Prints the number of stars to the console
 *                depending on the counts stored in an array.   
 *
 *  Sources:      Give references for the sources that you used in your 
 *                program if there areany
 **************************************************************************** */
package tes;
import java.util.Scanner;
import java.util.Base64;    
import javax.crypto.Cipher;  
import javax.crypto.KeyGenerator;   
import javax.crypto.SecretKey; 
public class tes {
          public static void main(String[] args) {
              Scanner sc = new Scanner(System.in);
              int a = 0;
              while (a != 6) {
                  System.out.println("                      ");
                  System.out.println("Select Operation:");
                  System.out.println("1:Addition");
                  System.out.println("2:Subtraction");
                  System.out.println("3:Multiplication");
                  System.out.println("4:Division");
                  System.out.println("5:Remainder");
                  System.out.println("6:Exit");
                  System.out.println("                      ");
                  System.out.print("Enter a choice: ");
                  int n = sc.nextInt();
                  a = n;
                  
                  if (n==6) {
                     break;
                  } 
                  else if(n==1) {
                     System.out.print("Please,enter the first number: ");
                     int n1 = sc.nextInt();
                     System.out.print("Please,enter the second number: ");
                     int n2 = sc.nextInt();
                     
                     System.out.println("Result of "+n1+"+"+n2+" is "+(n1+n2));
                  }
                  else if(n==2) {
                     System.out.print("Please,enter the first number: ");
                     int n1 = sc.nextInt();
                     System.out.print("Please,enter the second number: ");
                     int n2 = sc.nextInt();
                     
                     System.out.println("Result of "+n1+"-"+n2+" is "+(n1-n2));
                  }
                  else if(n==3) {
                     System.out.print("Please,enter the first number: ");
                     int n1 = sc.nextInt();
                     System.out.print("Please,enter the second number: ");
                     int n2 = sc.nextInt();
                     
                     System.out.println("Result of "+n1+"*"+n2+" is "+(n1*n2));
                  }
                  else if(n==4) {
                     System.out.print("Please,enter the first number: ");
                     int n1 = sc.nextInt();
                     System.out.print("Please,enter the second number: ");
                     int n2 = sc.nextInt();
                     if(n2==0) {
                         System.out.println("Please change the n2 value.");
                     }
                     else {
                         System.out.println("Result of "+n1+"/"+n2+" is "+(n1/n2));
                     }                
                     }
                  else if(n==5) {
                     System.out.print("Please,enter the first number: ");
                     int n1 = sc.nextInt();
                     System.out.print("Please,enter the second number: ");
                     int n2 = sc.nextInt();
                     
                     System.out.println("Result of "+n1+"%"+n2+" is "+(n1%n2));
                  }
              }
          }
}
/* *****************************************************************************
 *  Name:         Emre Cokcalışı
 *  Student ID:   6321211
 *  Department:   Industrial Engineering
 *
 *  Assignment ID: A1 Question 2 
 *
 *  Description:  Prints the number of stars to the console
 *                depending on the counts stored in an array.   
 *
 *  Sources:      Give references for the sources that you used in your 
 *                program if there areany
 **************************************************************************** */
class que2 {

    public static void main(String[] args) {
        String s1 = "Welcome to Java";
        String s2 = s1;
        String s3 = new String("Welcome to Java"); 
        String s4 = "Welcome to Java";
        
        System.out.println(s1 == s2);
        System.out.println(s2 == s3);
        System.out.println(s1.equals(s2));
        System.out.println(s2.equals(s3));
        System.out.println(s1.compareTo(s2));
        System.out.println(s1==s4);
        System.out.println(s1.charAt(0));
        System.out.println(s1.indexOf("j"));
        System.out.println(s1.indexOf("to"));
        System.out.println(s1.lastIndexOf("a"));
        System.out.println(s1.lastIndexOf("o", 15));
        System.out.println(s1.length());
        System.out.println(s1.substring(5));
        System.out.println(s1.substring(5, 11));
        System.out.println(s1.startsWith("Wel"));
        System.out.println(s1.substring(s1.lastIndexOf(" ")+1));
    }

}
/* *****************************************************************************
 *  Name:         Emre Cokcalışı
 *  Student ID:   6321211
 *  Department:   Industrial Engineering
 *
 *  Assignment ID: A1 Question 3 
 *
 *  Description:  Prints the number of stars to the console
 *                depending on the counts stored in an array.   
 *
 *  Sources:      Give references for the sources that you used in your 
 *                program if there areany
 **************************************************************************** */
class que3 {
    public static void main(String []args) { 
        int sum=0;
        // iterate from 0 to N 
        for (int num = 0; num < 51; num++) 
        {    
            // Short-circuit operator is used  
            if (num % 3 == 0 && num % 5 == 0){
                sum+=num;
                System.out.println(num+"");  
        }  
    }   System.out.println("Sum is: ");
        System.out.println(sum); 
}
    
}
/* *****************************************************************************
 *  Name:         Emre Cokcalışı
 *  Student ID:   6321211
 *  Department:   Industrial Engineering
 *
 *  Assignment ID: A1 Question 4 
 *
 *  Description:  Prints the number of stars to the console
 *                depending on the counts stored in an array.   
 *
 *  Sources:      Give references for the sources that you used in your 
 *                program if there areany
 **************************************************************************** */
class que4 {  
    static Cipher cipher;  

    public static void main(String[] args) throws Exception {
        KeyGenerator keyGenerator = KeyGenerator.getInstance("AES");
        keyGenerator.init(128); // block size is 128bits
        SecretKey secretKey = keyGenerator.generateKey();

        cipher = Cipher.getInstance("AES");

        String plainText = "AES Symmetric Encryption Decryption";
        System.out.println("Plain Text Before Encryption: " + plainText);

        String encryptedText = encrypt(plainText, secretKey);
        System.out.println("Encrypted Text After Encryption: " + encryptedText);

        String decryptedText = decrypt(encryptedText, secretKey);
        System.out.println("Decrypted Text After Decryption: " + decryptedText);
    }

    public static String encrypt(String plaTex, SecretKey sKey)
            throws Exception {
        byte[] Tb = plaTex.getBytes();
        cipher.init(Cipher.ENCRYPT_MODE, sKey);
        byte[] encryptedByte = cipher.doFinal(Tb);
        Base64.Encoder encoder = Base64.getEncoder();
        String encTex = encoder.encodeToString(encryptedByte);
        return encTex;
    }

    public static String decrypt(String encryptedText, SecretKey secretKey)
            throws Exception {
        Base64.Decoder decoder = Base64.getDecoder();
        byte[] encryptedTextByte = decoder.decode(encryptedText);
        cipher.init(Cipher.DECRYPT_MODE, secretKey);
        byte[] decryptedByte = cipher.doFinal(encryptedTextByte);
        String decTex = new String(decryptedByte);
        return decTex;
    }
}

/******************************************************************************
*名称:Emre Cokcalışı
*学号:6321211
*部门:工业工程
*
*作业编号:A1问题1
*
*描述:将星号打印到控制台
*取决于存储在数组中的计数。
*
*来源:提供您在应用程序中使用的来源的参考
*如果有,请编程
**************************************************************************** */
一揽子技术转让;
导入java.util.Scanner;
导入java.util.Base64;
导入javax.crypto.Cipher;
导入javax.crypto.KeyGenerator;
导入javax.crypto.SecretKey;
公开课{
公共静态void main(字符串[]args){
扫描仪sc=新的扫描仪(System.in);
int a=0;
而(a!=6){
System.out.println(“”);
System.out.println(“选择操作:”);
System.out.println(“1:添加”);
System.out.println(“2:减法”);
System.out.println(“3:乘法”);
System.out.println(“4:分部”);
系统输出打印项次(“5:余数”);
System.out.println(“6:Exit”);
System.out.println(“”);
System.out.print(“输入选项:”);
int n=sc.nextInt();
a=n;
如果(n==6){
打破
} 
else如果(n==1){
系统输出打印(“请输入第一个数字:”);
int n1=sc.nextInt();
系统输出打印(“请输入第二个数字:”);
int n2=sc.nextInt();
System.out.println(““+n1+”+“+n2+”的结果是“+(n1+n2));
}
else如果(n==2){
系统输出打印(“请输入第一个数字:”);
int n1=sc.nextInt();
系统输出打印(“请输入第二个数字:”);
int n2=sc.nextInt();
System.out.println(““+n1+”-“+n2+”的结果为“+(n1-n2));
}
else如果(n==3){
系统输出打印(“请输入第一个数字:”);
int n1=sc.nextInt();
系统输出打印(“请输入第二个数字:”);
int n2=sc.nextInt();
System.out.println(““+n1+”*“+n2+”的结果是“+(n1*n2));
}
else如果(n==4){
系统输出打印(“请输入第一个数字:”);
int n1=sc.nextInt();
系统输出打印(“请输入第二个数字:”);
int n2=sc.nextInt();
如果(n2==0){
System.out.println(“请更改n2值”);
}
否则{
System.out.println(““+n1+”/“+n2+”的结果为“+(n1/n2));
}                
}
else如果(n==5){
系统输出打印(“请输入第一个数字:”);
int n1=sc.nextInt();
系统输出打印(“请输入第二个数字:”);
int n2=sc.nextInt();
System.out.println(““+n1+”%“+n2+”的结果是“+(n1%n2));
}
}
}
}
/* *****************************************************************************
*名称:Emre Cokcalışı
*学号:6321211
*部门:工业工程
*
*作业编号:A1问题2
*
*描述:将星号打印到控制台
*取决于存储在数组中的计数。
*
*来源:提供您在应用程序中使用的来源的参考
*如果有,请编程
**************************************************************************** */
que2类{
公共静态void main(字符串[]args){
String s1=“欢迎使用Java”;
字符串s2=s1;
strings3=新字符串(“欢迎使用Java”);
String s4=“欢迎使用Java”;
System.out.println(s1==s2);
System.out.println(s2==s3);
系统输出println(s1等于(s2));
系统输出println(s2等于(s3));
系统输出打印LN(s1.与(s2)比较);
系统输出println(s1==s4);
System.out.println(s1.charAt(0));
系统输出打印LN(s1.indexOf(“j”));
System.out.println(s1.indexOf(“to”));
System.out.println(s1.lastIndexOf(“a”));
System.out.println(s1.lastIndexOf(“o”,15));
System.out.println(s1.length());
System.out.println(s1.子串(5));
System.out.println(s1.子串(5,11));
System.out.println(s1.startsWith(“Wel”));
System.out.println(s1.子字符串(s1.lastIndexOf(“”+1));
}
}
/* *****************************************************************************
*名称:Emre Cokcalışı
*学号:6321211
*部门:工业工程
*
*作为