Computer Science, asked by vishvanathdas2, 11 hours ago

what will be return by the following functions . float float next float ( ) ​

Answers

Answered by ParikshitPulliwar
1

Answer: public Float nextFloat()  

Explanation: import java.util.*;  

public class ScannerNextFloatExample1 {    

   public static void main(String args[]){      

       int amount;  

       double balance;  

       //Insert amount and balance from console  

       Scanner input = new Scanner (System.in);  

       System.out.print("Enter the amount: ");  

       amount = input.nextInt();  

       System.out.print("Enter the Total Balance: ");  

       balance = input.nextFloat();  

       //Reduce amount+fee from balance  

       balance = balance-(amount + 0.50);  

       //Print new balance  

       System.out.print("New Balance is: "+balance);  

     input.close();  

   }    

}  

Answered by ImpressAgreeable4985
0

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:

InputMismatchException: if the next token does not matches the Float regular expression, or is out of range

NoSuchElementException: if input is exhausted

IllegalStateException: if this scanner is closed

Similar questions