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
A class named clock has two instance variables : hours (type int ) and isticking (type boolean ). write a constructor that takes
Leno4ka [110]
<span>I guess you need it written in Java. So if you need only constructor, then here it is:
public Clock(Clock clock1) {
          this.hours = clock1.hours;
          this.isTicking = clock1.isTicking;
}

This code is 100% correct</span>
3 0
3 years ago
How to do c++ programming
Kipish [7]

Answer:

Explanation:

learn by picking up courses and books

but if you don't have any prior programming experience, i recommend you DON'T do c++ first, but instead use an easier language to get the hang of it, like Python.

8 0
3 years ago
Add me on xbox ahaha craig#6822 this is also just for points
Monica [59]

Answer:

sadly i dont have one:(

4 0
3 years ago
Read 2 more answers
What kind of storage is an internet service that provides storage to computer or mobile users?
Free_Kalibri [48]

Cloud is a kind of storage, which is an internet service that provides storage to computer or mobile users. This information technology enables ubiquitous access to shared pools of configurable system resources.

Time-critical data and images can be immediately viewed while away from a main office or location.

4 0
3 years ago
You learned that properly edited resumes are necessary for making a good impression on a university or a potential employer. Dis
beks73 [17]

Answer:

Resume is the important document for job seekers. As much as the resume is better, there is more chance to grab the job.

If the resume is poor, the employer may not call you for the interview.

Explanation:

Resume is the document that create and impression over the potential employer or university.

If someone have very good hard and soft skills, and does not mention all the skills in resume, then employer could not that skills that you may have. Because your resume is the document that represent you when you are not in front of the employer.  This is the first document, presented that, what  you are and how you are beneficial for the company.

<em>If your resume is poor it may cause that He cannot call you for the interview or not considered for that JOB.</em>

5 0
3 years ago
Read 2 more answers
Other questions:
  • Peter works on a huge database of numerical figures in a worksheet ranging from cell A1 to cell I50. He has to print the workshe
    10·2 answers
  • Which of the following is the path to the zoom button? select one:
    5·2 answers
  • The first project that this position will work on is an embedded sensor that will send readings periodically to the cloud, and h
    9·1 answer
  • What is the BCC feature used for?
    12·2 answers
  • Is there any difference beetween the old version of spyro released on the origional and the newer ones??? or is it only change i
    8·1 answer
  • What is the output by the code system.out.print(8-4+2);
    13·1 answer
  • Select the four bad password ideas.
    13·2 answers
  • Define Rule Of Thirds
    9·1 answer
  • What is destination email address​
    8·1 answer
  • Critical thinking questions
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!