Question: Write a static method called getTwoFloats(), which returns an array of two floats based on the problem 5.2 (Homework #5). You can re-use the code
Write a static method called getTwoFloats(), which returns an array of two floats based on the problem 5.2 (Homework #5). You can re-use the code you wrote from HW#5.2 or from the model answer provided. Modify the main method to call getTwoFloats and print the two floats in the main method.D getUserChoice.java D "Gettwofloats java X 1 import java.util.Scanner: 4 public class Gettwofloats { 6e public static void main(String[] args) { 7 Scanner read Input = new Scanner(System.in); float myFloat1 = e.ef; 9 float myFloat2 = e.ef; 10 System.out.print(" Welcome to get two floats program "); 12 do { // loop until we have correct input 13 System.out.print("Enter two floats separated by space : "); 14 try { myFloat1 = read Input.next Float(); // waits for user input myFloat2 = readInput.nextFloat(); // waits for user input break; 11 WVGUAWNE catch (final InputMismatchException e) { System.out.println("You have entered an invalid input. Try again."); read Input.nextLine(); //discard non float input continue; //keep looping until you found right one } while (true); System.out.println("InYou enter two valid floats:" + myFloat1 + " and " + myFloat2); System.out.println("Thank you for giving two floats"); // i have being getting stuck where after entering and invalid choice to get it to enter again vadoc Declaration Console X ofloats (Java Application) /Library/Java/Javavirtual Machines/jdk-13.0.1.dk/Contents/Home/bin/java (Feb 17, 2020, 6:52:30 PM)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
