Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

debug this Java code This program demonstrates an array of String and integer objects. It should print out the days and the number of speeding

 debug this Java code 

 


image

This program demonstrates an array of String and integer objects. It should print out the days and the number of speeding tickets given in the last 4 days of April on Spriggs Road. It should print out the day with the least number of speeding tickets. You must use the findLowest () method within your solution to find the lowest day. This is what should display when the program runs as it should April 27 had 12 tickets. April 28 had 10 tickets. April 29 had 15 tickets. April 30 had 17 tickets. Lowest Day has 10 tickets. public class SpeedingTicketsDebug { public static void main(String[] args) { String[] days = { "April 27", "April 28", "April 29", "April 30"}; int[] tickets = {12, 10, 15, 1,7}; int lowest = 0.0; String lowest Day = for (int index = 0; index < tickets. length; index++) { System.out.printf( "%s had %, d tickets. ", days [index], tickets [index]); lowest find Lowest (tickets); System.out.printf("Lowest Day has %, d tickets. ", lowest); //end of main public static double find Lowest(String[] myDays, int[] myTickets) { my Lowest = myDays [0]; for (int index = 1; index < myTickets.length index++) { if (myTickets [index] > lowest) { my Lowest = myTickets [index]; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Heres the corrected Java code with explanations for the changes public class SpeedingTicketsDebug pu... 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

C++ Primer Plus

Authors: Stephen Prata

6th Edition

978-0321776402, 0321776402

Students also viewed these Programming questions