method in class cannot be applied to given types

后端 未结 4 2159
傲寒
傲寒 2020-12-05 23:44

I\'m creating a program that generates 100 random integers between 0 and 9 and displays the count for each number. I\'m using an array of ten integers, counts

相关标签:
4条回答
  • 2020-12-06 00:05

    call generateNumbers(numbers);, your generateNumbers(); expects int[] as an argument ans you were passing none, thus the error

    0 讨论(0)
  • 2020-12-06 00:17

    generateNumbers() expects a parameter and you aren't passing one in!

    generateNumbers() also returns after it has set the first random number - seems to be some confusion about what it is trying to do.

    0 讨论(0)
  • 2020-12-06 00:20

    The generateNumbers(int[] numbers) function definition has arguments (int[] numbers)that expects an array of integers. However, in the main, generateNumbers(); doesn't have any arguments.

    To resolve it, simply add an array of numbers to the arguments while calling thegenerateNumbers() function in the main.

    0 讨论(0)
  • 2020-12-06 00:23

    I think you want something like this. The formatting is off, but it should give the essential information you want.

       import java.util.Scanner;
    public class BookstoreCredit 
    {
    
       public static void computeDiscount(String name, double gpa) 
       {
          double credits;
          credits = gpa * 10;
          System.out.println(name + " your GPA is " +
             gpa + " so your credit is $" + credits);
       
       }
    
       public static void main (String args[]) 
       {
          String studentName;
          double gradeAverage;
          Scanner inputDevice = new Scanner(System.in);
          System.out.println("Enter Student name: ");
          studentName = inputDevice.nextLine();
          System.out.println("Enter student GPA: ");
          gradeAverage = inputDevice.nextDouble();  
          
          computeDiscount(studentName, gradeAverage);
       }
    }
    
    0 讨论(0)
提交回复
热议问题