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)
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 }?
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?
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?
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?
A. What does void mean? B. Will Java complain if a returned value is not stored/printed?...
A. What does void mean? B. Will Java complain if a returned value is not stored/printed? C. Can you return more than one variable in Java? D. What happens if code exists after a return statement?
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?
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT