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
Sandy's keyboard is not inputting data into her computer which key should she press to verify it is connected to her computer...
Ksivusya [100]

Answer:

Windows key,capslock key for verify connectivity

Explanation:

Sandy's can verify whether her keyboard is working or not by pressing the windows key. Caps Lock and Num lock key will turn on the light on keyboard and she shall see whether her keyboard is functioning or not. This method is being used everywhere to verify the keyboard connectivity.The light function can also be checked by using Caps Lock or Num lock key as well. Some keyboard offers the in built light, which can be turned on by pressing Alt+Space bar.

5 0
3 years ago
Consider tree from the lectures on slide 10, write down the nodes in order as pro-
Leto [7]
The work same to be level order traverse and the sea is completely
7 0
2 years ago
Which subexpression will be solved first in the given statement?
Crazy boy [7]

Answer:

If you dont buy terraria than im going to make mrbeast buy it for you

Explanation:

reeeeeeeeeeeeeeeeeeeee

4 0
3 years ago
Which of the following tools might the security administrator use to perform further security assessment of this issue?
Y_Kistochka [10]

Answer:

A.Port scanner

Explanation:

thats correct answer★

4 0
2 years ago
WILL GIVE BRAINLIEST!!!!!!!!!
sukhopar [10]

Answer:

True

Explanation:

7 0
2 years ago
Other questions:
  • Explain the concept of risk management, including risk identification, assessment, and control.
    5·1 answer
  • When configuring a vpn server to automatically assign ​ip addresses to remote clients, how many ip addresses are in a single poo
    10·1 answer
  • How to cancel branly subscription??​
    8·1 answer
  • your friend's parent's are worried about going over their budget for the month. Which expense would you suggest is NOT a need?
    11·1 answer
  • Which line of code will eliminate the element “calculator” from an array of supplies?
    13·1 answer
  • Hvhblfffffffff<br> eafafaefafsa
    9·2 answers
  • Project introduction​
    14·1 answer
  • Read the citation example, and then use the drop-down menus to identify each part.
    8·2 answers
  • Match the elements used in web searches to their functions.
    12·1 answer
  • When working with track changes, what is the difference between simple markup and all markup?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!