Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

If anyone is able to help me resolve this project im working on, getting Excepti

ID: 3744104 • Letter: I

Question

If anyone is able to help me resolve this project im working on,

getting

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0

D Euclid.java × 2 Univeristy of Central Florida 3 COP3330 - Fall 2018 Author: 6 7 package gcdpackage; 8 9 public class Euclid 10 11 public static void main(String args[]) 12 13 14 15 16 17 18 19 20 21 int a-Integer.parseInt (args 0 int b- Integer.parseInt(args [11); System.out.println(); System.out.println("--"); System.out.println("Euclid's Algorithm by System.out.println("Inputs: "+a+", +b); System.out.println(); if(a>b) calGcd(a,b); else calGcd (b,a); 23 24 25 public static void calGcd(int a, int b) 26 27 28 29 30 31 32 int q, r-10,mul; while(r!=0) q-a/b; mul-q*b; r-a-mul; System . out . printin(a+" "+q+" x "+b+" + "+r); 34 35 36 37 38 39 40 41 42 ber; if(r-e) System.out.println("Gcd : "+a); TasksConsole Euclid (3) [Java Application] C:Program FilesJavajdk1.8.0_181 binjavaw.exe (Sep 7, 2018, 1:37:19 PM Exception in thread "main" java.lang.ArrayIndexOutofBoundsException:e at gcdpackage.Euclid.main(Euclid.java:13)

Explanation / Answer

if(args.length == 0) { System.out.println("Provide a and b as command line arguments to this program"); } // Add this code in the beginning of the main // just before line 13 // after line -> public static void main(String[] args) // { // You were getting that error because you did not provide 2 integers as command line arguments to this program. // I am not familiar with how to add program arguments in eclipse. // But I am sure you can find that out easily with a google search.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote