Write a method named negative sum

Assignment Help C/C++ Programming
Reference no: EM13160964

Write a method named negativeSum that accepts a Scanner as a parameter reading input from a file containing a series of integers, and determine whether the sum starting from the first number is ever negative. The method should print a message indicating whether a negative sum is possible and should return true if a negative sum can be reached and false if not. For example, if the file contains the following text, your method will consider the sum of just one number (38), the sum of the first two numbers (38 + 4), the sum of the first three numbers (38 + 4 + 19), and so on up to the sum of all of the numbers: 38 4 19 -27 -15 -3 4 19 38 None of these sums is negative, so the method would produce the following message and return false: no negative sum If the file instead contains the following numbers, the method finds that a negative sum of -8 is reached after adding 6 numbers together (14 + 7 + -10 + 9 + -18 + -10): 14 7 -10 9 -18 -10 17 42 98 It should output the following and return true, indicating that a negative sum can be reached: -8 after 6 steps 

Reference no: EM13160964

Questions Cloud

List two functions of cilia in protists : List two functions of cilia in protists and to relate one or bothof these functions to the ciliated cells of multi-cellularorganisms.
A program called invoice that will prompt the user for items : write a program called invoice that will prompt the user for items on and invoice and then print the total of the invoice
What exactly is the krebs cycle : What exactly is the Krebs cycle? please break it down if you can.
Write a program that reads from a file a list of course name : Write a program that reads from a file a list of course names, letter grades for each course and number of credits each course is worth. The program will read each course name, grade earned and number of credits from the file and print out the course..
Write a method named negative sum : Write a method named negativeSum that accepts a Scanner as a parameter reading input from a file containing a series of integers, and determine whether the sum starting from the first number is ever negative
Describe the lifecycle of plasmodium : Describe the lifecycle of Plasmodium, the parasite that causes malaria.Start with infection. Describe the role of the sporozoites,merozoites, and gamteocytes in the life cycle, and specify whereyou will find each of these forms of the parasite.
Enlightenment in France-Great Britian and German states : What were the major diffeences between the Enlightenment inFrance, Great Britian, and the German states? What were the common themes and aims of the Enlighenmentwritings?
What is the genotypic ratio of blondes : Does anyone know how to solve this question? I've been trying butcan't seem to get it right. If anyone could help me I would greatlyappreciate it.
Declare a vector : Declare a vector of these structures where the size of the vector is to be 7.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write two short c programs and solve exam-style problem

Write two short C programs and solve four exam-style problems.

  Execute tests and repetitions

Read data from standard input and store them in an array, Execute tests and repetitions

  Function that returns the height of a binary tree

Write a function called getHeight() that returns the height of a given binary tree - CptS 122 Write a function called countSmallerThan() that returns the number of nodes whose values are smaller than the supplied input paramter

  Create a template class

Create a template class, SVector, that implements a constructor

  Write a matrix multiplication program

Write a C++, matrix multiplication program which you can instrument to monitor and measure execution time as a function of problem size. Make sure it works in Microsoft Visual Studio.

  Implement database having array of pointers

One way to implement this database is to have an array of pointers pointing to Employee objects. You will obviously require a function named Calculate_salary() which will be different for each employee class. Write code in c++

  Write a loop that fills a vector

Write a loop that fills a vector V with ten  different  random numbers between 1 and 100. output must actually display the random numbers to get credit.

  Create a program for a company named retail-mart

Prompt the user to enter an item name (one word only), a quantity and a price. For this step, in addition to functionality, I'll be looking at: location of the variable declarations; appropriateness of data types selected; appropriateness of the va..

  Create class integerset

Create class IntegerSet for which each object can hold integers in the range 0 through 100. Represent the set internally as a vector of bool values. Element a[i] is true if integer i is in the set. Element a[j] is false if integer j is not in the set..

  Functions to compute stress and strain in steel rod

Write a main function and the following functions to compute the stress and strain in a steel rod of diameter D (inches) and length L (inches) subject to the compression loads P of 10,000 to 1,000,000 pounds.

  Implement method to advance any given date by one day

Write C++ implementation of this method. Create and specify any other methods that you require. Include comments which will be helpful to someone who will maintain implementation in the future.

  Write program which inputs number of winning coupons

Write a program which inputs number of coupons you win and outputs how many candy bars and gumballs you can get if you spend all off your coupons on candy bars first and remaining coupons on gumballs in c++.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd