Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students also viewed these Databases questions

Question

the number 8 i both even and a power of 2

Answered: 1 week ago

Question

6. Discuss the steps involved in conducting a task analysis.

Answered: 1 week ago

Question

8. Explain competency models and the process used to develop them.

Answered: 1 week ago