what is nextFloat give one example
Answers
Answer:
Scanner nextFloat() method in Java with Examples
The nextFloat() method of java.util.Scanner class scans the next token of the input as a Float(). If the translation is successful, the scanner advances past the input that matched.
Syntax:
public float nextFloat()
Parameters: The function does not accepts any parameter.
Return Value: This function returns the Float scanned from the input.
Exceptions: The function throws three exceptions as described below:
pls add as brainliest andwer
Answer:
nextFloat() method scans the next token of the input as a float. This method will throw InputMismatchException if the next token cannot be translated into a valid float value as described below. If the translation is successful, the scanner advances past the input that matched.Example 4
import java.util.*;
public class ScannerNextFloatExample4 {
public static void main(String args[]){
Float number;
Scanner scan = new Scanner( System.in );
System.out.print("Enter the numeric value : ");
number = scan.nextFloat();
System.out.println("Float value : " + number +" \nTwice value : " + 2.0*number );
Explanation:
Please mark this answer as brainliest..