Answered step by step
Verified Expert Solution
Link Copied!

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 ?

image text in transcribed

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

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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

Write an equation for each parabola. 2 (2, 2) (0, 1) -2 -2

Answered: 1 week ago

Question

Does positivity have a place in the workplace? Explain.

Answered: 1 week ago