Question

In: Computer Science

1. In Java, what does the last line mean? What does scan.nextLine(); mean?

1. In Java, what does the last line mean? What does scan.nextLine(); mean?

import java.util.Scanner;

Scanner scan = new Scanner (System.in);

message = scan.nextLine();

2. Assuming that a Random object has been created called generator, what is the range of the result of each of the following expressions? Also, do each example using nextFloat()

•generator.nextInt(20)

•generator.nextInt(8) + 1

•generator.nextInt(100) – 50


Solutions

Expert Solution

message = scan.nextLine() means reads the string from the console

•generator.nextInt(20) : will generate the number between 0-20

•generator.nextInt(8) + 1: wll generate numbers between 1-9

•generator.nextInt(100) – 50 : will generate from -50 to 50

nextFloat() is user to generate floating point numbers


Related Solutions

Java is often called a middleware platform. What does this mean?
Java is often called a middleware platform. What does this mean?
Which java collection have you used the most? and why? What does static mean in Java...
Which java collection have you used the most? and why? What does static mean in Java and when should you use it? (Both static variable and static method) What does abstract keyword mean in java and when should you use? (Both abstract class and method)
Simon Sinek made a statement “ Leaders Eat Last”. What does this mean to be a...
Simon Sinek made a statement “ Leaders Eat Last”. What does this mean to be a leader that eats last? How can you apply this concept as a Licensed Nursing health Administrator of a nursing facility?
In java, what does it mean when a variable "exists" from its declaration to }?
In java, what does it mean when a variable "exists" from its declaration to }?
What does "Electric potential is the negative line integral of electric field" mean?
What does "Electric potential is the negative line integral of electric field" mean?
If the residual positive, what does that mean and how does it compare with the line of best fit? What about if the residual is negative?
If the residual positive, what does that mean and how does it compare with the line of best fit? What about if the residual is negative?a) What does it mean if the residual is close to 0? What if the residual isn't close to 0?b) How would each of these residuals appear in a scatter plot?
What is Last Pass? What is Java Language Applets?
What is Last Pass?What is Java Language Applets?What is Code Red?What is computer incident?
In Orwell's 1984 what does it mean when Winston saysthe he is "the last man"?
In Orwell's 1984 what does it mean when Winston says the he is "the last man"?
IMF is also known as the “lender of last resort”. What does that mean? Please give...
IMF is also known as the “lender of last resort”. What does that mean? Please give us an example.
Leonardo da Vinci painted The Last Supper, what does it mean that Christ's head is the...
Leonardo da Vinci painted The Last Supper, what does it mean that Christ's head is the point of emphasis in a triangle? I need the answer at least 10 sentence with citation proof.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT