Java 如何一次运行一个void?

Java 如何一次运行一个void?,java,eclipse,Java,Eclipse,我对java非常陌生,我是一名学生,正在学习java。我想知道如何一次运行一个“void”publicstaticvoidpracticemath()。因此,在控制台中,只显示该方法的主体,而不是主方法中包含的所有其他内容。我使用eclipse public class Ch2Challenges { /** * Complete at least 3 of the following problems * using Dialog boxes. You choic

我对java非常陌生,我是一名学生,正在学习java。我想知道如何一次运行一个“void”
publicstaticvoidpracticemath()
。因此,在控制台中,只显示该方法的主体,而不是主方法中包含的所有其他内容。我使用eclipse

public class Ch2Challenges
{
    /**
     * Complete at least 3 of the following problems 
     * using Dialog boxes. You choice of which ones. 
     */


    public static void PracticeMath ()
    {
        /*
         * Use the MathClass to create a program that
         * will calculate and display the following: 
         *  1. absolute value of posNum and negNum (Google it)
         *  2. num1 raised to the power of num2
         *  3. The square root of square
         *  4. the maximum and minimum values of num1 and num2 (Google it)
         *  5. the distance between posNum and negNum (Google it)
         *  6. the length of the hypotenuse of a right triangle 
         *      when the user inputs two values for leg1 and leg2 
         *      rounded to 2 decimal places  
         */

        Scanner sc2 = new Scanner(System.in);

        int posNum = 12, negNum = -15;
        int num1 = 2, num2 = 6;
        int square = 49;
        double leg1, leg2, hypotenuse;  

        System.out.println("Data Set");
        System.out.println("==========");
        System.out.println("posNum = " + posNum);
        System.out.println("negNum = " + negNum);
        System.out.println("num1 = " + num1);
        System.out.println("num2 = " + num2);
        System.out.println("Square = "+ square);

        int posNum1 =  java.lang.Math.abs(posNum);
        int negNum1 = java.lang.Math.abs(negNum);
        int range = (posNum-negNum);
        int range1 = java.lang.Math.abs(range);

        System.out.println("The absolute value of posNum is " + posNum1 + ", and the absolute value of negNum is " + negNum1 + "." );
        System.out.println("num1 ^ num2 = " + Math.pow(num1, num2));
        System.out.println("Maximum number of num1 & num2 = " + Math.max(num1, num2));
        System.out.println("Minimum number of num1 & num2 = " + Math.min(num1, num2));
        System.out.println("The between posNum & negNum contains " + range + " numbers.");
        System.out.println("Lets calculate the hypotenuse of a right triangle...");
        System.out.print("Enter in a value for the first leg of your triangle ===> ");
        leg1 = sc2.nextDouble();
        System.out.print("Enter in a value for the second leg of your triangle ===> ");
        leg2 = sc2.nextDouble();
        hypotenuse = Math.sqrt(Math.pow(leg1, 2)+(Math.pow(leg2, 2)));
        System.out.printf("With leg 1 = %.2f and leg 2 = %.2f Your hypotonuse is %.2f", leg1 , leg2 , hypotenuse );











    }

    public static void Time ()
    {
        /*
         * Write a program that allows the user to enter the number of seconds.  
         * The program should calculate the equivalent number of hours, 
         *  minutes and seconds.  
         *  Example:  9999 seconds = 2 hours, 46 minutes, and 39 seconds. 
         *      (Hint: modulus is your friend)
         */


        //#NOTE! REMEMBER TO USE MOD- BY DEV
         Scanner sc = new Scanner(System.in);
         System.out.println("Seconds Converter");
         System.out.println("---------------------");
         System.out.print("Enter the amount of seconds you would like converted ===> ");
         int seconds = sc.nextInt();
         int secs = seconds % 60;
         int hrs = seconds / 60;
         int mins = hrs % 60;

         System.out.print( hrs + " Hours, " + mins + " Minutes, " + secs + " Seconds.");


    }

    public static void Paint ()
    {
        /*
         * 1. Declare integers length, width, height 
         * 2. Declare doubles totalSqFt, paintNeeded 
         * 3. Declare and initialize object scanner
         * 4. Prompt for and read in the length of the room
         * 5. Prompt for and read in the height of the room
         * 6. Prompt for and read in the width of the room
         * 
         * calculations  
         * 7. Compute the total square feet of the walls to be painted
         * 8. Compute the amount of paint needed
         *  Remember, you can't buy a fraction of a paint can
         *      Round UP!
         *
         * output
         * 9. calculations rounded to 2 decimal places 
         * 10. Print the length, width, and height of the room 
         *      and the gallons of paint needed.
         */

    }

    public static void IDNumbers()
    {
        /*
         * Different identification numbers have different ways of 
         *  calculating their check-digit.  
         * Write a program that will calculate the check digit for 
         *  airline tickets using the following information:  
         *  
         *  Airline tickets divide the actual identification 
         *      number by 7 and assign the remainder to the check digit.  
         *  ID Numbers can be of any length. 
         *  
         *  Example:    12358 check # 3
         */

    }
    public static void RestaurantBill ()
    {
        /*
         * Write a program that computes the tax and tip on a restaurant bill. 
         * The program should ask the user to enter the charge for the meal. 
         * The tax should be 7.5 percent of the meal charge.
         * The tip should be 18 percent of the total after adding the tax. 
         * Display the meal charge, tax amount, tip amount, and total bill on the screen.
         * Ensure the display is professional, absent of any typos and clear. 
         * All dollar amounts should be formatted with commas, two decimal places.
         * All percents should be rounded to one decimal place. 
         */
        Scanner sc1 = new Scanner(System.in);
         double stateTax = 0.255;
        double bill;
        System.out.println("Restaurant Bill Calc");
        System.out.println("------------------------");
        System.out.print("Enter the Bill ===> ");
        bill = sc1.nextDouble();

        //some tax things
        double billWithTax = (bill*stateTax);


        //some tip things

        double totalCost = (bill + billWithTax);


        System.out.printf("With the tax equaling 7.5%% of the bill and the tip equaling 18%%, the total is equal to %.2f", totalCost);

    }
    public static void MaleFemale ()
    {
        /*
         * Write a program that asks the user for the number of males and 
         *  the number of females registered in a class. 
         *  The program should display the percentage of males and females in the class. 
         *  Ensure the display is professional, absent of any typos and clear. 
         */

    }
    /** 
     * Challenges: These are available to everyone; Give them a try!
     */

    public static void PaintDoorWindow()
    {
        /*
         * Suppose the room has doors and windows that don't need painting.
         * Ask the user to enter the number of doors and number of windows 
         * in the room, and adjust the total square feet to be painted accordingly.
         * Assume that each door is 25 square feet and each window is 20 square feet.
         */

    }
    public static void AmexIdNumber ()
    {
        /*
         * An American Express traveler’s check has a check digit so that 
         * it makes the sum of the digits, including the check digit, 
         * evenly divisible by 7.  
         * For this activity, assume there are 4 digits ID numbers, plus a check digit.
         * 
         * Example:     3875 check # 5 
         */

    }
    public static void main(String [] args)
    {
        PracticeMath();
        Time();
        Paint();
        IDNumbers();
        RestaurantBill();
        MaleFemale();
        PaintDoorWindow();
        AmexIdNumber();        
    }
}```

请添加完整的Java代码,前提是这些代码可以合理地包含在您的问题中。@TimBiegeleisen AlrightyYou只需注释或从主方法中删除不需要的方法。。。