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
Interruption attacks are also called ___ attacks:
Lelu [443]

Answer:

Interruption attack are also referred to as Denial Of Service(DOS) attack.

Explanation:

Interruption attack are also called denial of service.The main aim of  interruption attack or Denial Of Srvice attack is to make resources unavailable.

For example:- wordpress.com had an DOS attack that took down their servers hence the service was unavailable for it's users.

Hence we conclude that the answer to this question is Denail of Service (DOS).

4 0
3 years ago
Which PowerPoint options can users customize?
Zielflug [23.3K]

Answer:

Customized Toolbar,  theme, design, autosave file location, ribbon tabs and groups, quick access buttons, username

Explanation:

5 0
3 years ago
An operating system that allows a single user to work on two or more programs at the same time is what type of OS?
Lisa [10]

Answer:

Explanation:

The correct answer is none of these

An operating system that allows a single user to perform only one task at a time is called a Single-User Single-Tasking Operating System. Functions like printing a document, downloading images, etc., can be performed only one at a time. Examples include MS-DOS, Palm OS, etc.

Advantage: This operating system occupies less space in memory.

Disadvantage: It can perform only a single task at a time.

There are four types of operating systems −

Real-time operating system

Single-User/Single-Tasking operating system

Single-User/Multitasking operating system

Multi-User/Multitasking operating system

Real-time operating system is designed to run real-time applications. It can be both single- and multi-tasking. Examples include Abbasi, AMX RTOS, etc.

An operating system that allows a single user to perform more than one task at a time is called Single-User Multitasking Operating System. Examples include Microsoft Windows and Macintosh OS.

It is an operating system that permits several users to utilize the programs that are concurrently running on a single network server. The single network server is termed as "Terminal server". "Terminal client" is a software that supports user sessions. Examples include UNIX, MVS, etc.

5 0
2 years ago
MCQ: Which of the following network is confined to a relatively small area?
kobusy [5.1K]

Answer:

<em>D Lan</em><em>.</em><em>.</em><em>.</em><em>.</em><em>.</em><em>.</em><em>.</em><em>.</em><em>.</em><em>.</em><em>.</em><em>.</em><em>.</em><em>.</em><em>.</em><em>.</em><em>.</em><em>.</em><em>.</em>

3 0
2 years ago
Read 2 more answers
A type of specialty processor devoted exclusively to protecting your privacy.
drek231 [11]
 Cryptoprocessor would be it.
8 0
3 years ago
Read 2 more answers
Other questions:
  • Which Command Prompt commands in Windows is used for listing a computer connections to shared resources
    10·1 answer
  • Discuss how and why video game hardware affects game design and where you think the next generation of platforms will change tho
    9·1 answer
  • The expressionvecCont.empty() empties the vector container of allelements.
    13·1 answer
  • A ___ is the basic collective unit of data in a computer.
    12·1 answer
  • There are varying definitions for the term "dumb terminal," but it often refers to the fact that the terminal has
    13·1 answer
  • Write a program to enter a number and test if it is greater than 45.6. If the number entered is greater than 45.6, the program n
    10·1 answer
  • A finally clause will execute:
    8·1 answer
  • Which of the following statements is NOT true about url extension?
    10·2 answers
  • C++ Write a program that initially asks a user to enter two positive integer numbers a and b. If either a or are zero or negativ
    9·2 answers
  • Write a method that takes a Rectangle as a parameter, and changes the width so it becomes a square (i.e. the width is set to the
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!