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
In order to create a horizontal 2-inch-thick dotted green line exactly 2 inches away from the top of the canvas, a graphic artis
Harrizon [31]

Answer:

I Think meter .

Explanation:

Not so Sure

4 0
3 years ago
Read 2 more answers
I think you have been doing a great job but you haven’t been signing many people up for our new service feature I want you to se
STatiana [176]

Answer:

24 customers

Explanation:

Given

Customers = 96

p = 25\% --- proportion to sign up

Required

The number of customers to sign up

This is calculated as:

n = p * Customers

So, we have:

n = 25\% * 96

n = 24

5 0
3 years ago
Ebay employs the _____ auction mechanism.
myrzilka [38]

Answer:

A. Foward

Explanation:

4 0
3 years ago
Read 2 more answers
What pressure will be shown on the high side peessure gauge (ac system on)
maria [59]
H tht would be the correct answer
8 0
4 years ago
When Building a resume what would i put when it says field of study especially when your still going to high school?​
Nastasia [14]
Just put Still attending or Enter Highschool then if they ask you about it just let them know your still attending, that’s what I did and got the job on the spot
6 0
3 years ago
Other questions:
  • A company wants to build a webpage that displays KPIs that can be derived from values in datasets stored in Einstein Analytics.
    6·1 answer
  • Some languages are traditional programming languages for developing applications; others, such as markup and scripting languages
    12·1 answer
  • As text is typed in the _____ text box, a drop-down list displays options for completing the action, displaying information on t
    11·1 answer
  • What does the format painter button do?
    13·1 answer
  • Q13. On which option do you click to
    12·1 answer
  • Write a function solution that, given an integer N, returns the maximum possible
    8·1 answer
  • Brainly is brainly am I correct ​
    11·2 answers
  • LaShawn would like to post photos in a social media app, but the program needs to be modified in order to display a greater vari
    12·2 answers
  • I have no idea how to use the sep and end in Python can someone help me I have a test tomorrow
    13·1 answer
  • List resource you can utilize if you are experiencing technology issued
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!