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
muminat
3 years ago
11

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 = courseGrades.length - 1.
Note: These activities may test code with different test values. This activity will perform two tests, both with a 4-element array. 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.
import java.util.Scanner;
public class CourseGradePrinter {
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
final int NUM_VALS = 4;
int [] courseGrades = new int[NUM_VALS];
int i;
for (i = 0; i < courseGrades.length; ++i) {
courseGrades[i] = scnr.nextInt();
}
/* Your solution goes here */
}
}
Computers and Technology
1 answer:
ozzi3 years ago
6 0

Answer:

The missing part of the code is:

for (i = 0; i < courseGrades.length; ++i) {

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

       System.out.println();

       for (i = courseGrades.length-1; i >=0 ; --i) {

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

       System.out.println();

Explanation:

This iterates through the array

for (i = 0; i < courseGrades.length; ++i) {

This prints each element of the array followed by a space

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

This prints a newline at the end of the loop

       System.out.println();

This iterates through the array in reverse

       for (i = courseGrades.length-1; i >=0 ; --i) {

This prints each element of the array (reversed) followed by a space

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

This prints a newline at the end of the loop

       System.out.println();

You might be interested in
How can you logout your account and do not want to have this anymore
hram777 [196]

Answer:

Just Click Log out!

Explanation:

Its Simple, really! I promise its real

5 0
3 years ago
Read 2 more answers
balance exercises used for introducing balance training should initially involve little joint motion and improve what type of co
liubo4ka [24]

The balance exercises used for introducing balance training should initially involve little joint motion and improve the Reflexive (automatic) joint-stabilization contractions.

<h3>What is the main goal of balance training?</h3>

Balance training is known to be a kind of an exercise where a person that is doing the  exercises works out so as to strengthen the muscles that aids  them to keep to be upright, such as their  legs and core.

Note that  kinds of exercises are done so as to improve stability and help hinder falls.

Therefore, The balance exercises used for introducing balance training should initially involve little joint motion and improve the Reflexive (automatic) joint-stabilization contractions.

Learn more about balance exercises  from

brainly.com/question/16218940

#SPJ1

5 0
1 year ago
Using JavaScript, how does a web page react when the user enters a wrong email ID in a registration form?
Irina18 [472]

The correct answer is B.

5 0
3 years ago
The data structure used for file directory is called
Aleks04 [339]
This is a tough question. I’m not sure if I’ll get it right but I’ll try.

Data structures used for file directories typically have a hierarchical tree structure, referred to as a directory structure. The tree has a root directory, and every file in that system has a unique path.

The simplest method of implementing a directory is to use a linear list of file names with pointers to the data blocks. But another way that you can format a file directory is by using a hash table. With this method, the linear list stores the directory entries, but a hash data structure is also used. The hash table takes a value computed from the file name and return the pointer to the file name any linear list.

So I think it’s C. But I’m not 100% sure.

I hope that helps.
6 0
3 years ago
PLEASE HELP
kramer
Style  would be the great and best answer but you could add office decor
7 0
3 years ago
Read 2 more answers
Other questions:
  • In number theory, a perfect number is a positive integer that is equal to the sum of its proper positive divisors, that is, the
    12·1 answer
  • Which type of attack modifies the fields that contain the different characteristics of the data that is being transmitted?
    7·1 answer
  • What were the goals of the “paperless society” ideal?
    14·2 answers
  • This program has some errors in it that are needed to be checked import java.io.*;
    13·1 answer
  • When computing the cost of the basket of goods and services purchased by a typical consumer, which of the following changes from
    11·1 answer
  • web pages within the same website often have different blank because they have different blank A) home pages, urls B) goals, sou
    12·1 answer
  • The operating system provides a ____, which is the means with which you interact with the computer
    5·1 answer
  • to edit text boxes in a template, first A click on the text box you want to edit B begin typing C format the front D drag the te
    5·2 answers
  • What is the code for this please?​
    13·1 answer
  • What is the console.log function for?​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!