Define a Java class named Accumulator

profileTopsolutions
 (Not rated)
 (Not rated)
Chat

1. Define a Java class named Accumulator. The class contains the following elements:
a. An integer variable named total.
b. A method named getTotal() that returns the value of total. This method does not take any arguments.
c. A method named add() that takes one integer argument. This method increases the value of total by the value of the argument. This method does not return any value.


2. Write a Java method remove() that takes two arguments: a String and a single character. This method should return a new String that contains all the characters from the input String without any occurrences of the specified character. For example, remove("this is some text", ‘s’) should return “thi i ome text”. You may assume that all input values are in lowercase. Use a loop to build up the result String, character by character. Do NOT use the String method replace()!

    • 12 years ago
    Solution
    NOT RATED

    Purchase the answer to view it

    blurred-text
    • attachment
      accumulator.docx