Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(Java) Help with checking for invalid input using try and catch. Looking for help adding the try and catch in my code to check for

(Java) Help with checking for invalid input using try and catch.

Looking for help adding the try and catch in my code to check for zero, negative numbers, and letters.image text in transcribed

File Edit source Refactor Navigate Searth Project Rui Window Help A My FirstClass lava la 1 import java util Scanner 2 publ class HyFirstriass 3e public static void main string args) 4 Creating an array for user entered weights and declaring some variables 5 ble rd Weight new bleL5 6 int i; otalHeigh double t 8 ble avrrageel ight a; 9 ble nexWeight 0; 10 Syst 13 for (i 0; i i Taking 5 weieht inputs tror user and putting it in array 15 entered eights[i next Double 17 nt Statement for all user entered Wrights LE System.out.print nter weight (i 1 ln 19 Calculating total weight 21 totalnleight entered Weights[i 22 24 if(entere eights [i] maxWeight) maxweight entered Heights 28 System.out print You entered //Printing all 5 user entered weights 31 for (i 92 Syst out-p entered eights Print 34 Calculating Average Weigh 35 average Weight Wright)/5.6 Print Statenents or total, average and max Heights 31 Systel ut.p 3g System.out.print WnTotel height: totalleight); ln 4e Average weight average eight); 41 Syst print in("Max ght maxle ight return 47 ust v 8, My FirstClass mainstringal Void

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

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

More Books

Students also viewed these Databases questions