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
Please help with my Python code - Functions
ollegr [7]

Answer:

Explanation:

see attached for help

7 0
3 years ago
Sal Kan earned $3,000.00, But he is only getting $1,585.00 on his pay check to
svetlana [45]

Answer:

Usually, it's because of taxes and insurance.

3 0
3 years ago
Write the addReview method, which adds a single product review, represented by a ProductReview object, to the ReviewCollector ob
maw [93]

Answer:

Explanation:

namespace Jeroen\ReviewIntegration\Observer;

use Magento\Framework\Event\ObserverInterface;

class ProductReview implements ObserverInterface

{

    protected $_storeManager;

    protected $_request;

    public function __construct(

        \Magento\Store\Model\StoreManagerInterface $storeManager,

        \Magento\Framework\App\Request\Http $request

    ) {

        $this->_storeManager = $storeManager;

        $this->_request = $request;

    }

    public function execute(\Magento\Framework\Event\Observer $observer)

    {

         return 'test';

    }

}

5 0
3 years ago
I WILL MARK THE BRAINIEST!!!!!!!!!!!!! 50 POINTS!!!!!!!
Sauron [17]
Hello,

Your answer would be:

1. It’s important to have a good study skill so you can be ready to take a quiz such as world history.

2. It’s important to know your time on tasks because you don’t want to spend all day on one simple task you want to get things done.

3. A schedule can help you get organzied because it helps you with your time such as this go along with your second question.

Have a nice day :)

~Rendorforestmusic
5 0
3 years ago
Read 2 more answers
Stella likes to work with colors and moving pictures. She is good at drawing. Which job role should she choose
PilotLPTM [1.2K]

Answer:

Digital Art or Animator for moving picture art.

Explanation:

7 0
3 years ago
Read 2 more answers
Other questions:
  • A company that hires only American Indians is practicing
    5·2 answers
  • Is a fundamental building block of a relational database because this object stores all of the data
    15·1 answer
  • What is meant by polling mode in communication between software andUART and what is its disadvantage as compared to interrupt mo
    14·1 answer
  • Determine the number of bytes necessary to store an uncompressed binary image of size 4000 × 3000 pixels
    11·1 answer
  • A(n) is the tool that will help you the most when developing the content you will use in your presentation.
    10·1 answer
  • Copy the countdown function from Section 5.8 of your textbook. def countdown(n): if n &lt;= 0: print('Blastoff!') else: print(n)
    8·1 answer
  • Help giving points mark BRAINLEST
    5·1 answer
  • Why are mobile phone called cell phones?​
    13·1 answer
  • Computer network reduces the cost. explain the statement with example.​
    8·1 answer
  • What bonnie is this? From five night at freddys
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!