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
3 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]3 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
What is a systems development life cycle?
gogolik [260]

Answer: D) The overall process for developing information systems from planning and analysis through implementation and maintenance.

Explanation:

System development life cycle(SDLC) is the mechanism in the cyclic form for describing about the development stages of information system.The stages involves in production of system are analysis, design, implementation, planning and maintenance. It is used for making non-technical as well as technical models of information systems.

Other options are incorrect because high stage planning, feature description or evaluation of end-users business is not done by SDLC(System development life cycle) models.

Thus, the correct option is option(D).

7 0
4 years ago
How can our perceptions help us to choose the channel for our message?
nevsk [136]
Our Perceptions helps us to choose the channel for our message by how we judge or categorized things. This action is called perceiving which means to realize or understand. Perception refers to our abilities we can do through our senses such as to see, to hear, and to feel.
8 0
3 years ago
What does ieee stand for
Ganezh [65]
This stands for institute of electrical and electronics engineers

Good luck!
7 0
3 years ago
Read 2 more answers
One of the most obvious initial changes in windows vista is the ____ interface
lana [24]
Answer choices are not provided, but I would go for "Aero."
8 0
3 years ago
Which type of computer graphic can be resized without affecting image quality or getting distorted?
BartSMP [9]
Vector graphics can be rescaled without losing quality and each property can be changed like the colour, shape and size. 

Even if an object in a vector large, it doesn't need a lot of memory. Hence, the file size of a vector graphic is often very small.


8 0
3 years ago
Other questions:
  • How do switches and bridges learn where devices are located on a network?
    5·1 answer
  • What is the most effective way to demonstrate being prepared for an interview?
    8·2 answers
  • What are the three business writing formats
    12·1 answer
  • NEED ASAP!!
    14·1 answer
  • The operation of early electronic computing devices required:
    8·1 answer
  • If a website ends with .gov does it mean that its written by the government or?
    11·2 answers
  • What is the definition of D1-D4?
    14·1 answer
  • Which of the following is an example of a consumer
    14·2 answers
  • Can i have help for a ggogle class room
    14·1 answer
  • Which of the following tiny computer apps is designed to be useful but could cause more harm than good?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!