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
Alchen [17]
3 years ago
3

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 = NUM_VALS - 1.


Note: These activities may test code with different test values. This activity will perform two tests, the first with a 4-element array (int courseGrades[4]), the second with a 2-element array (int courseGrades[2]). See How to Use zyBooks.

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.

code:

import java.util.Scanner;

public class CourseGradePrinter {
public static void main (String [] args) {
final int NUM_VALS = 4;
int[] courseGrades = new int[NUM_VALS];
int i = 0;

courseGrades[0] = 7;
courseGrades[1] = 9;
courseGrades[2] = 11;
courseGrades[3] = 10;


return;
}
}
Computers and Technology
1 answer:
Maru [420]3 years ago
4 0

Answer:

The code to this question can be described as follows:

Code:

System.out.println("first we simply prints array value, then prints value in reverse order: "); //message

//loop to print array value  

for(i=0; i<NUM_VALS; ++i) //using for loop

{

System.out.print(courseGrades[i]+" "); //print values

}  

System.out.print("\n");

//loop to print array value in reverse order  

for(i=NUM_VALS-1; i>=0; --i) //using for to print value in reverse order  

{

System.out.print(courseGrades[i]+" "); //print value

}

Explanation:

In the above code two for loop is declared, in which first loop it prints array value normally, and in the second loop it prints array value in its reverse order, the working of both loops can be described as follows:

  • In the first for loop, the "i" variable is used that starts from 0 and ends when the value of "i" is less than "NUM_VALS", inside the loop it prints its value.
  • In the second loop, the "i" variable starts from "NUM_VALS-1", and ends when the value of i is greater than equal to 0, and inside the loop, the print method is used that prints array value in reverse order.
You might be interested in
Different algorithms can be made to complete the same task in different ways.
musickatia [10]

Answer:

True hope this helps you and everyone!

7 0
3 years ago
Read 2 more answers
Which of the following are agricultural industry clusters? Human population systems, computer technoloy biotechnology or food pr
GalinKa [24]

Biotechnology

Food Products and Processing Systems.

Further explanation

Career clusters help prepare learners with knowledge that they need to use towards achieving their career goals. One such career cluster is the Agriculture, Food, and Natural Resources career cluster which is divided into seven pathways. They include:

  • Food Products and Processing Systems.
  • Biotechnology Systems
  • Agribusiness Systems
  • Plant Systems
  • Animal Science
  • Environmental Service Systems
  • Natural Resource Systems

This brings us to our answers above. Those working in the Food Products and Processing Systems pathway are responsible in discovering new food sources and coming up with ways to process and store food set out by industry regulation. On the other hand, biotechnology systems deal with techniques that use science to solve problems concerning living organisms and anyone thinking about pursuing this pathway ought to demonstrate competence in the application of biotech in the context of Agriculture, Food, and Natural Resources.

Learn about Agriculture, Food, and Natural Resources career cluster

brainly.com/question/6457497

brainly.com/question/11364780

#LearnWithBrainly

6 0
3 years ago
Yo who do u add a pic on here
Juliette [100K]
Go to the me colum when you first open the app
8 0
3 years ago
A _____ is relatively inexpensive to install and is well-suited to workgroups and users who are not anchored to a specific desk
KengaRu [80]

Answer:

B) wireless local area network (WLAN)

Explanation:

WLAN which fully meaning is WIRELESS LOCAL AREA NETWORK is a network provider that enables two or more mobile phone user , desktop or computer user to connect and have access to the internet by simply connecting to the local area wireless network and this type of wireless network are more cheaper to install.

Example of where WIRELESS LOCAL AREA NETWORK can be found are : School building, Office building, School campus, home, among others.

4 0
3 years ago
Please help me!
BaLLatris [955]

Answer:

Choose what you think based on this.

Explanation:

with a for loop:

>>> students = 3

>>> for student in range(students):

>>> print(student)

would output

>>> 0

>>> 1

>>> 2

with a while loop now:

>>> students = 3

>>> student = 0

>>> while student < students:

>>> student = student + 1

>>> print(student)

the for loop is more compact than the while loop. But there may be some times when a you cant do a for loop. The first question is more than likely definite but I don't know the second answer.

8 0
3 years ago
Read 2 more answers
Other questions:
  • Behaving in an acceptable manner within a workplace environment is referred to as having
    9·1 answer
  • Discuss the differences between permanent internal memory and volatile internal memory.
    14·1 answer
  • Alpha Technologies, a newly established company, wants to share information about its work with people all over the world. Which
    9·1 answer
  • Microsoft excel is a __________ application.
    5·1 answer
  • What is my favorite color?<br> Red<br>Orange<br>Yellow<br>Blue <br>Gold<br>Silver
    13·1 answer
  • ---------------is a systematic review of a person’swork and achievements over a recent period, usually leading toplans for the f
    11·1 answer
  • Ok so I usually don’t do this but I just need an answer , on Instagram a notification popped up while I was watching someone’s s
    9·2 answers
  • Represent the measuring unit ofcomputer un terms of fration of second​
    13·1 answer
  • The system where the unit of measurement is centimeter
    15·1 answer
  • List and describe four services that comprise IT infrastructure, beyond physical devices and software applications.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!