Question

Java

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

bold answer

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: If you have any queries related to the answer please do comment. I would be very happy to resolve all your queries.

public class Test{

public static void main(String []args){
int hourlyTemp[]={90,92,94,95};
for(int i=0;i<hourlyTemp.length-1;i++)
System.out.print(hourlyTemp[i]+", ");
System.out.print(hourlyTemp[hourlyTemp.length-1]);
  
}
}

Llı Result Sjavac Test.java Execute > Share Source File STDIN 1- public class Test{ 2 public static void main(String [] args)

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
Java bold answer Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate elements with a...

    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, 95 Your code's output should end with the last element, without a subsequent comma, space, or newline. import java.util.Scanner; public class PrintWithComma {    public static void main (String [] args) {       Scanner scnr = new Scanner(System.in);       final int NUM_VALS = 4;       int[] hourlyTemp = new...

  • 7.2.3: Printing array elements with a for loop. Write a for loop to print all elements...

    7.2.3: Printing array elements with a for loop. 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. (Notes) Also note: If the submitted code tries to access an invalid...

  • C programming only please 5.2.3: Printing array elements with a for loop. Write a for loop...

    C programming only please 5.2.3: Printing array elements with a for loop. 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. (Notes) Note: These activities may test code with...

  • in java Feedback? CHALLENGE ACTIVITY 5.2.2: Printing array elements. Write three statements to print the first...

    in java Feedback? CHALLENGE ACTIVITY 5.2.2: Printing array elements. Write three statements to print the first three elements of array run Times. Follow each statement with a newline. Ex: If runTime = (800,775, 790, 805, 808) print: 800 775 790 Note: These activities will test the code with different test values. This activity will perform two tests, both with a 5 element array. See 'How to Use zyBooks". Also note: If the submitted code tries to access an invalid array...

  • Write the code that will print out all elements in the int array called numbers, separated...

    Write the code that will print out all elements in the int array called numbers, separated by spaces, and a newline character after all elements are printed.

  • In java please :-) 12 values have been input into array yearlyValues. Output all 12 elements,...

    In java please :-) 12 values have been input into array yearlyValues. Output all 12 elements, with 4 per line. If the elements are 10 20 30 40 50 60 70 80 90 100 110 120, the output is: 10 20 30 40 50 60 70 80 90 100 110 120 Hints: • Use a for loop with increment i += 4, rather than ++i. • Inside the for loop, just print all four elements using four print statements. An...

  • What control structure does Java use to process all elements in a collection? A do-while loop....

    What control structure does Java use to process all elements in a collection? A do-while loop. A for loop. A for-each loop. A while loop. Which of the following is a valid Java array declaration? String array s[10]; String[] s; String[10] s; Array String[] s; Which of the following references will get the last element in an array of n elements named a? a[n-1] a[n] a[n+1] a

  • Write three statements to print the first three elements of array runTimes. Follow each statement with...

    Write three statements to print the first three elements of array runTimes. Follow each statement with a newline. Ex: If runTime = {800, 775, 790, 805, 808}, print: 800 775 790 Note: These activities will test the code with different test values. This activity will perform two tests, both with a 5-element array. See "How to Use zyBooks". Also note: If the submitted code tries to access an invalid array element, such as runTimes[9] for a 5-element array, the test...

  • write a java program that does the following Part one Use a For loop to compute...

    write a java program that does the following Part one Use a For loop to compute the sum of all the odd numbers from 1 through 99. Your result should be labeled, and the value should be 2500. Print your name 7 times using a While loop. String dogNames[ ] = {"Sam","Buster","Fido","Patches","Gromit","Flicka"}; Using the array defined here, print the values of the array vertically and horizontally using one For-Each loop. Reverse the logic (Nested loops: Indent text) so that the...

  • Q1. Write a program in Java         a. Create 2 separate arrays, of user defined values,...

    Q1. Write a program in Java         a. Create 2 separate arrays, of user defined values, of same size         b. Add these 2 arrays. ........................................................................................................................... Q2. Write a program in java (using loop) input any10 numbers from user and store in an array. Check whether each of array element is positive, negative, zero, odd or even number. ............................................................................................................................ Q3. Write a program in Java to display first 10 natural numbers. Find the sum of only odd numbers. .............................................................................................................................. Q4....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT