asked 166k views
1 vote
Can you please correct the code below? The error reads

: In function ‘int main()’:
:2: error: expected primary-expression before ‘/’
token 6 | / method that will prin

asked
User Deadbug
by
7.9k points

1 Answer

7 votes

Answer:

import java.util.Random;

import java.util.Scanner;

public class RandomNumberGenerator {

public static void main(String[] args) {

// Create a Scanner object to read input from the user

Scanner scanner = new Scanner(System.in);

System.out.print("Enter the number of random numbers to generate: ");

int n = scanner.nextInt();

System.out.print("Enter the minimum value for the random numbers: ");

double min = scanner.nextDouble();

System.out.print("Enter the maximum value for the random numbers: ");

double max = scanner.nextDouble();

// Create a Random object to generate random numbers

Random random = new Random();

System.out.println("Random Numbers:");

for (int i = 0; i < n; i++) {

double randomNum = min + (max - min) * random.nextDouble();

System.out.println(randomNum);

}

// Close the scanner

scanner.close();

}

}

answered
User Renato Aquino
by
8.9k points