Ask Question
11 September, 23:36

Given that the array monthSales of integers has already been declared and that its elements contain sales data for the 12 months of the year in order (i. e., January, February, etc.), write a statement that writes to standard output the element corresponding to October. Do not write anything else out to standard output.

+2
Answers (1)
  1. 11 September, 23:52
    0
    System. out. println ("October is the "+monthSales[9]+"th Month of the year");

    A complete Java program is given in the explanation section.

    Explanation:

    public class num4 {

    public static void main (String[] args) {

    int [] monthSales = new int[12];

    int i=0;

    for (i = 0; i
    monthSales[i] = i+1;

    }

    System. out. println ("October is the "+monthSales[9]+"th Month of the year");

    }

    }

    In the code above, we created an an array of size 12 with this statement

    int [] monthSales = new int[12];

    using the for loop, the numbers 0-12 are added to the array corresponding to the twelve months in the year

    The statement System. out. println ("October is the "+monthSales[9]+"th Month of the year"); outputs the corresponding number to October
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Given that the array monthSales of integers has already been declared and that its elements contain sales data for the 12 months of the ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers