Java 我被Is元音和printAll方法卡住了

Java 我被Is元音和printAll方法卡住了,java,methods,Java,Methods,我对Java还不熟悉,到目前为止,它还没有在我的脑海中出现。这是我的作业,我在两种方法上有困难。有人能帮我把它弄清楚吗。也谢谢,我在哪里可以学会什么时候使用什么方法?我看了一些youtube,这很有帮助,但我们的教科书模糊不清。提前谢谢你的帮助。这是我的密码 /** The public class below is the name of your java program. */ import java.util.Scanner; public class ProblemSet6 {

我对Java还不熟悉,到目前为止,它还没有在我的脑海中出现。这是我的作业,我在两种方法上有困难。有人能帮我把它弄清楚吗。也谢谢,我在哪里可以学会什么时候使用什么方法?我看了一些youtube,这很有帮助,但我们的教科书模糊不清。提前谢谢你的帮助。这是我的密码

/** The public class below is the name of your java program.
*/
import java.util.Scanner;
public class  ProblemSet6 {
  public static void main(String[] args) {
    //Prompt user for a number
    System.out.print("Enter a number: ");
    double userInput = input.nextDouble();


  }//Ending main method

  /**
* Method Description: Write a method, square, that takes in one number      and 
* returns the square of that number.
*
* This method takes in one number and returns one number. Do not use   Math.pow().
*
* @param x: x is the number that double uses from user input to calculate the return
* @returns and will return x squared 
 */      
   public static double square(double x) {
     return x*x;
   }  //end square method

   /**
* Method Description: Write a method, evalQuadratic, that returns the value of the 
* quadratic a(x*x)+bx+c.
*
* @param x: This method takes in four numbers (a, b, c, and x) and returns a single number.
* Note you are not trying to solve for x, it is already given.

* @returns the value of the quadratic as evalQuadratic
 */

   public static double evalQuadratic(double x, double a, double b,    double c) { 
      return (a*(x*x) + b * x + c);  


   } // end of Quadratic Method

   /**
* Method Description: This method will take a number and raise it to the fourth power.
* Use the square Method from above.
* @param x will be the same "x" input from the begining.
* return the answer of whatever is "x" raised to the fourth power
 */

   public static double fourthPower(double x) {
  return square(square(x));

   } //end of fourthPower Method

   /**
* Method Description: This Method will tell you if the number returned    is odd or even.
* Write a method, odd, that takes in one number and returns True when the number is odd and False otherwise.
* Remember what % (mod) operator does and what it means to be an even/odd number.
* This method takes in one number and returns a boolean.
* @ param x will be determined if it is odd or even.
* @ return boolean odd is true and even is false.
 */

    public static boolean odd(double x) {


        //
      if(x % 2 ==0) return false;
      else return true;


    } // end of odd(boolean) Method 

  /*  
* Define a method isVowel(char c) that returns True if the char is a vowel
* ('a', 'e', 'i', 'o', or 'u'), and False otherwise. 
* You can assume that char is a single letter of any case 
* (ie, 'A' and 'a' are both valid).
* This method takes in one char and returns a boolean.
   */
     public static boolean isVowel(char c) {


        //
      if(c == (a | e | i | o | u)) return true;
     else return false;


    } // end of isVowel(boolean) Method 

  /*
* Write a method, printAll, that takes no parameters and returns nothing.
* This method prints out all of the other methods. For any method that needs
* parameters, use any parameters you wish (Scanner or putting numbers in)
   */


     public static void printAll(){  
       System.out.println(square(userInput));
       System.out.println(evalQuadratic(userInput)); 
       System.out.println(fourthPower(userInput));
       System.out.println(odd(userInput));
       System.out.println(isVowel());

    }


} // end of class

你的方法行不通。|运算符是位级别上的OR操作,这肯定不是您想要的

您可以将代码更改为一组检查,类似这样:

if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')){
但这是非常冗长和容易出错的

我建议采用这种方法:

用所有已知元音填充已排序的字符数组 将该数组存储在私有静态final字段中 对该数组执行一次检查
是的,这是我写的代码,不会编译。下面是错误代码java:14:error:找不到符号double userInput=input.nextDouble;^symbol:变量输入位置:类ProblemSet6java:104:错误:找不到symbol System.out.printlnsquareuserInput@戴维布兰查德:我已经编辑了我的答案。这应该是这样的。java:105:error:not find symbol System.out.printlnevalQuadraticuserInput;^symbol:variable userInput location:class ProblemSet6thanks我在java中待的时间不长,所以老师可能不会喜欢我使用数组,对我的printAll方法有什么建议吗?它不喜欢我的userInput
if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')){