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
Hoochie [10]
3 years ago
11

Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate elements with a comma and space. Ex: If hourlyTemp

= {90, 92, 94, 95}, print:90, 92, 94, 95Note that the last element is not followed by a comma, space, or newline.import java.util.Scanner;public class PrintWithComma {public static void main (String [] args) {final int NUM_VALS = 4;int[] hourlyTemp = new int[NUM_VALS];int i = 0;hourlyTemp[0] = 90;hourlyTemp[1] = 92;hourlyTemp[2] = 94;hourlyTemp[3] = 95;/* Your solution goes here */System.out.println("");return;}}
Computers and Technology
1 answer:
slavikrds [6]3 years ago
3 0

Answer:

Here are the for loop for the given question.

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

       {

         /* check if the value of i is equal to NUM_VALS or not.If it is

         equal then just print the value without comma.*/

       if(i==(NUM_VALS-1))  // if block

       System.out.print(hourlyTemp[i]);

  /* if i is not equal then just print the value with comma.*/

       else   // else block

       System.out.print(hourlyTemp[i] + ", ");

       }

Explanation:

In this we iterating the for loop  and check the condition

check if the value of i is equal to NUM_VALS or not.If it is  equal then just print the value without comma

If i is not equal then just print the value with comma .

Output:

90,92,94,95

You might be interested in
When you adopt a certain framework or strategy for solving a series of problems, you may fail to see other, more efficient ways
Olegator [25]
I believe it is called closed mindset. Closed mindset is when you fail to see other ways to your error and don't accept help or think you can improve.
7 0
4 years ago
A vehicle fails an HC emission test at idle and 2,500 rpm, and the engine has an acceleration stumble. The heated oxygen sensor
Marina CMI [18]
I'm thinking that it is B. If I am wrong I am very sorry.
6 0
4 years ago
Read 2 more answers
Which of the following is a locate tool that will enable you to navigate to cell M291?
scoundrel [369]

just answered it its<u><em> Go To</em></u>

3 0
4 years ago
Which of the following are some popular debugging techniques?
topjm [15]

Answer:

a fix any syntax bugs. I looked it up on the internet so you should be good good luck on your test

8 0
3 years ago
What is the name given to a value that does NOT change when used within a formula? *
CaHeK987 [17]
The answer is C. constant.
6 0
3 years ago
Read 2 more answers
Other questions:
  • Dinah is using an I.D.E to write, modify, and save code. Which tool should she use?
    8·2 answers
  • Each frame is composed of a number of colors recorded in digital format; we call these pixels. What information does the number
    15·1 answer
  • Is Windows a:<br><br> A.operating system<br> B.software<br> C.hardware<br> D.input device
    12·1 answer
  • The mac group does not replace the primary functions of eocs or other dispatch organizations. True or False
    8·1 answer
  • Write a function called list_codons which takes a single argument called orf (expected to be a string representing an ORF sequen
    7·1 answer
  • Considering the concept of salted passwords, answer the following questions: a. Bob thinks that generating and storing a random
    10·1 answer
  • 50) Universal Containers has an integration that runs nightly to update the Product (Product2) object in Salesforce with updated
    9·1 answer
  • True/False/Unknown. For the interpretation of function calls, we assign the formal parametersto the valuations of the actual arg
    11·1 answer
  • Give the uses of Word’s mail merge.
    8·1 answer
  • Imaging a computer is part of what phase of conversion?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!