1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
meriva
2 years ago
6

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 newline. Ex: If courseGrades = {7, 9, 11, 10}, print:
7 9 11 10
10 11 9 7

Hint: Use two for loops. Second loop starts with 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 4-element array, the test may generate strange results. Or the test may crash and report "Program end never reached", in which case the system doesn't print the test case that caused the reported message.

code:

import java.util.Scanner;

public class CourseGradePrinter {
public static void main (String [] args) {
final int NUM_VALS = 4;
int[] courseGrades = new int[NUM_VALS];
int i = 0;

courseGrades[0] = 7;
courseGrades[1] = 9;
courseGrades[2] = 11;
courseGrades[3] = 10;


return;
}
}
Computers and Technology
1 answer:
KatRina [158]2 years ago
4 0

Answer:

Java code explained below

Explanation:

CourseGradePrinter.java

import java.util.Scanner;

public class CourseGradePrinter {

public static void main (String [] args) {

final int NUM_VALS = 4;

int[] courseGrades = new int[NUM_VALS];

int i = 0;

courseGrades[0] = 7;

courseGrades[1] = 9;

courseGrades[2] = 11;

courseGrades[3] = 10;

for(i=0; i<NUM_VALS; i++){

  System.out.print(courseGrades[i]+" ");

}

System.out.println();

for(i=NUM_VALS-1; i>=0; i--){

  System.out.print(courseGrades[i]+" ");

}

return;

}

}

Output:

7 9 11 10

10 11 9 7

You might be interested in
How to upgrade brainly membership
rjkz [21]

Answer:

Go on account settings, go to subscription, and upgrade.

Explanation:

7 0
3 years ago
Read 2 more answers
What are spreadsheets in a excel workbook called? A. pages B. notepads C.graphs D.worksheets
galina1969 [7]
D. Worksheets
I’m positive this is the correct answer
4 0
3 years ago
What is the most appropriate data type for each of these items?
Tom [10]
I may be wrong, BUT here is what i think



b) line graph


d) pie graph
7 0
2 years ago
What is the best application to create a slide show presentation?
Lynna [10]

Answer:

Microsoft Windows File Manager

5 0
3 years ago
Read 2 more answers
How do you change a LAN (local area network) to a WAN (wide-area network)
ahrayia [7]

Answer:

Go to internet, click use as LAN under the cable section and click yes to confirm

4 0
2 years ago
Other questions:
  • What is intensity? this is for digital arts
    12·1 answer
  • NullPointerException and ArithmeticException are both derived from which class?
    10·1 answer
  • Consider the recursive method myprint in this code snippet: public void myprint(int n) { if (n &lt; 10) { system.out.print(n); }
    5·1 answer
  • Binary is best interpreted by a computer because?
    8·2 answers
  • ERP implementation probably will not require:
    8·2 answers
  • Can someone start me off with a short 2 or 3 paragraphs about the pros and cons of Microsoft Word, and if you can recommend a si
    12·1 answer
  • Custom actions help your users by
    6·1 answer
  • what will allow you to immediately exit the program without rebooting the computer, when you realize your browser is not respond
    7·1 answer
  • Which of the following guidelines about the subject line of e-mail messages is most appropriate?
    15·2 answers
  • HELP MEEE PLEASE!!!
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!