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
Company-wide systems that connect one or more local area networks (LANs) or wide area networks (WANs) are called _____.
fgiga [73]
Web-centric systems
3 0
2 years ago
Hello safiya77 this is for you
Ray Of Light [21]
Hello astropiggy!
Feel free to ask any question!
I’ll try my best to answer them!
5 0
2 years ago
Cisco's acquisition of Pure Digital, makers of the Flip video camera line, was largely considered a flop because comparable tech
juin [17]

Answer:

True

Explanation:

8 0
3 years ago
Read 2 more answers
. What year did the USA host World Cup? Right answer 1994
Ksivusya [100]

Answer:

USA host World Cup in 1994 1994 FIFA World Cup

Explanation:

USA host World Cup in 1994 FIFA World Cup

it was the 15th edition of FIFA World Cup

and Brazil was won the tournament

Brazil beat Italy by 3–2 in  penalty shoot-out

it was play between 17 June to 17 July and 24 team play this World Cup

and there matches played = 52

and 9 cities host this game

United States of America was chosen as the host by FIFA on the 4 July, 1988

5 0
2 years ago
When considering the typical characteristics of a server, how is the server optimized in relation to applications?
VLD [36.1K]

Answer: Server are optimized so that they can work efficiently and improve their performance while working. Application server optimization mechanism can be used for optimizing the server with respect to the application.

Some of the techniques used in the application server optimization are as follows:-

  • Load balancing- which helps in upgrading throughput ,improves the time of response, enhance the bandwidth of network etc.
  • Fail-over management- it is used for decrement of latency, balancing the server, increasing the availability of network and it resources etc.

3 0
3 years ago
Other questions:
  • What year did bill gates form traf-o-data?
    8·1 answer
  • Which of the following are advantages of cloud computing?
    6·2 answers
  • What is Least effective at preventing a computer virus
    10·1 answer
  • you just bought a new hard drive for your computer you plan to use this as a second hard drive to store all your you made files
    6·1 answer
  • Write a program in which given an integer num, return the sum of the multiples of num between 1 and 100. For example, if num is
    7·1 answer
  • Do you watch markiplier?
    13·2 answers
  • What is an Operating System ??
    7·1 answer
  • Does anyone have a rbx account? If they do friend request Tribalchief777
    8·1 answer
  • What is the purpose of the ISOWEEKNUM function? determines how many workdays are in a certain week determines how many workdays
    12·2 answers
  • question 1 scenario 1, question 1-5 you’ve just started a new job as a data analyst. you’re working for a midsized pharmacy chai
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!