Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For Java Programming (not Javascript) 1. 2. 3. 4. 5. Write a for loop to print a

ID: 3664329 • Letter: F

Question

For Java Programming (not Javascript)

1.

2.

3.

4.

5.

Write a for loop to print all elements in courseGrades, following each element with a space (including the last). Print forwards, then backwards. End each loop with a ne Ex: lf courseGrades 17, 9, 11, 10), print: 79 11 10 10 119 7 Hint: Use two for loops. Second loop starts w th i NUM VALS 1 Note: These activities may test code with different test values. This activity will perform two tests, the first with a 4-element array (int courseGrades[4]), the second with a 2-element array (int courseGrades[2]). See How to Use zyBooks. Also note: If the submitted code tries to access an invalid array element, such as courseGrades[9 for a ment array, the test may generate strange results. Or the test may crash and report "Program end reached", case never in which the system doesn't print the test case that caused the reported message. 1 import java util. Scanner 3 public class courseGradePrinter 4 public static void main (String args) final int NUM VALS. 43 int[I courseGrades new int[ VALS NUM int i 0; course Grades 7; course Grades[1 9; 10 course Grades[2 11 11 course Grades[3] 10 12 13 Your solution goes here 14 15 return; 16 17 18

Explanation / Answer


import java.io.*;

public class courseGradePrinter
{
public static void main(String[] args) throws IOException
{
//Declaring variables
BufferedReader dataIn = new BufferedReader(new InputStreamReader(System.in));
   String grade, strSize;
   float average;
   int size;

System.out.print("How many grades will you enter? ");
   strSize = dataIn.readLine();
       size = Integer.parseInt(strSize);
       float grades[] = new float[size];

for (int i=0; i<size; i++)
{
//Get input from user
System.out.print("How many grades will you enter? ");
       strSize = dataIn.readLine();
      size = Integer.parseInt(strSize);

}

   average = averageGrades(grades, size);

//Write a for loop to display grades

System.out.println("");
System.out.println("The average grade was "+average);
}

public static float averageGrades(float[] g, int s)
{
   float total = 0;
   float a;
   // write a for loop to calculate the total

   a = total / s;
   return a;
}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote