Ask Question
31 January, 14:08

Assume that a Money variable yearlySales has also been declared. Write the necessary code that traverses the monthlySales array and adds it all up and stores the resulting total in yearlySales. Be sure make sure that yearlySales ends up with a valid value, i. e. a value of cents that is less than 100.

+5
Answers (1)
  1. 31 January, 17:22
    0
    public class num3 {

    public static void main (String[] args) {

    double yearlySales = 0;

    int [] monthlySales = new int[12];

    for (int i = 0; i
    yearlySales = yearlySales + = monthlySales[i];

    }

    }

    }

    Explanation:

    Declare the variable yearlySales and initialize to 0.

    Create an Array of ints monthlySales, set its length to 12

    Using a for loop, add up all the elements in array and store in the varible yearly sales.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Assume that a Money variable yearlySales has also been declared. Write the necessary code that traverses the monthlySales array and adds it ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers