Answered step by step
Verified Expert Solution
Question
1 Approved Answer
What are the errors of this code ? 1 import java.io.*; 2 3 4 6 7 8 9 import java.util.*; // Declare class public class
What are the errors of this code ?
1 import java.io.*; 2 3 4 6 7 8 9 import java.util.*; // Declare class public class Sum{ public static void main (String [] args) throws FileNotFoundException{ } Scanner input = new Scanner (System.in); string numbers = input.nextLine(); boolean result = negativeSum (numbers); //System.out.println(result); //STATIC METHOD negativeSum BEGINS HERE 10 11 12 13- 14 15 16 18 19 // 20-> 21- public static boolean negativeSum(Scanner numbers) { int sum e; // NUMBER COUNT int count e; // SUMMATION OF NUMBERS boolean neg = false; // LOOP THROUGH ARRAY OF NUMBERS string[] nums = numbers.split(" "); PARSE STRING INTO AN INTEGER for (int i = 0; i < nums.length; i++) { try{ 22 // IF THE STRING IS AN INTEGER, ADD IT TO SUM int num = Integer.parseInt(nums[i]); 23 count++; sum = sum + num; if (sum 40 41 } 42 43 44 System.out.println("No negative sum"); return neg; } Execute Mode, Version, Inputs & Arguments For Multip steps ");
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started