Question

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 5

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

Answer:

Give me a thumbs up if you like my work !!!

I have written the below Java Program based on your requirements.

Just Save the below code as Main.java and then Compile & Run the code. It will work smoothly.

The below code has no-error and it is working perfectly.

I have also attached the Output Screenshot that I got by running the below program.

Output:

4. Command Prompt C:\Users\Public>javac Main.java C:\Users\Public>java Main 10 20 30 40 50 60 70 80 90 100 110 120 10 20 30 4

*******************************************************************************************************************

Code:

Main.java

import java.io.*;
import java.util.*;

public class Main
{
   public static void main(String[] args)
   {
       Scanner sc=new Scanner(System.in);
      
       int yearlyValues[]=new int[12];
      
       for(int i=0;i<12;i++)
       {
           yearlyValues[i]=sc.nextInt();
       }
      
       for(int i=0;i<12;i+=4)
       {
System.out.print(yearlyValues[i]+" ");
           System.out.print(yearlyValues[i+1]+" ");
           System.out.print(yearlyValues[i+2]+" ");
           System.out.print(yearlyValues[i+3]);
          
           System.out.println();
       }
   }
}

Add a comment
Know the answer?
Add Answer to:
In java please :-) 12 values have been input into array yearlyValues. Output all 12 elements,...
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
  • Using C++ Insert elements into a partially filled array. a) Create a partially filled array of...

    Using C++ Insert elements into a partially filled array. a) Create a partially filled array of CAPACITY 100. b) Initialize the array with values 10,20,30,40,50,60,70,80,90,100 c) Create a print function for the array. d) Create an insert function which inserts an integer into the array in sorted position. e) Insert the numbers 5, 150 and 55. f) Print the array before and after each insertion. Output Example 10 20 30 40 50 60 70 80 90 100 5 10 20...

  • Please match the compound to its spectrum and explain why cpd 22 Spectrum A 100- 60...

    Please match the compound to its spectrum and explain why cpd 22 Spectrum A 100- 60 40 20 100 125 50 75 m/z Spectrum B 100 80- 60 40 20- 10 20 30 40 50 60 70 0 90 100 110 120 m/z (6 points) Match EOT Spectrum C 100- 80- 60 40 75 100 125 50 m/z Spectrum D 100 80 60- 40 20- 25 50 75 100 125 m/z Spectrum E 100 80 60 20 10 20 30...

  • a) b) c) The graph below depicts an industry that has been monopolized. 120 110 S...

    a) b) c) The graph below depicts an industry that has been monopolized. 120 110 S 100 90 80 PRICE ($) 70 60 50 — 40 30 20 D MR 1 1 - - - 20 30 50 60 70 40 OUTPUT If this market is in equilibrium, the price = and output = Is there any deadweight loss? (yes or no) If a monopoly raised the price to $80, the approximate output be . At this new price, would...

  • Identify which of these four mass spectra indicate the presence of sulfur, chlorine, bromine, iondine, nitrogen....

    Identify which of these four mass spectra indicate the presence of sulfur, chlorine, bromine, iondine, nitrogen. suggest a molecular formula for each. 2otten breaks sh ass spec er be mass PROBLEM 12-7 Identify which of these four mass spectra indicate the presence of sulfur, chlorine bromine, iodine, or nitrogen. Suggest a molecular formula for each. AA gIve the lonica 100 77 80 156 158 (a) 60 40 20 Fragn 10 20 30 40 50 60 70 80 100 110 120...

  • Java bold answer Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate...

    Java bold answer Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate elements with a comma and space. Ex: If hourly Temp = {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.

  • Identify which of these four mass spectra indicate the presence of sulfur, chlorine, bromine, iodine, or...

    Identify which of these four mass spectra indicate the presence of sulfur, chlorine, bromine, iodine, or nitrogen. Suggest a molecular formula for each. 100 abundance 8 $ 38 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 mily abundance 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 z 8 8 8 abundance $ 8 LL 10 20 30 40 50 60 70 80 90 100 110...

  • Match each compound (d) to its mass spectrum (1-4). ) Relativel y 30 40 50 60...

    Match each compound (d) to its mass spectrum (1-4). ) Relativel y 30 40 50 60 70 80 90 100 110 120 18 Mars plastic 2 STAEDTLER Revente 20 30 40 50 60 70 80 90 100 110 120 130 Relative intensy 10 20 30 40 50 60 70 80 90 100 110 120 130

  • Please refer to the following table displaying cost and revenue data for a monopolist. If this...

    Please refer to the following table displaying cost and revenue data for a monopolist. If this monopolist seeks to maximize economic profit, what price should it charge for this good? Output Price Total Revenue Marginal Revenue Total Cost Marginal Cost Average Total Cost 0 $120 $0 na $100 na na 1 $110 $110 $110 $120 $20 $120 2 $100 $200 $90 $150 $30 $75 3 $90 $270 $70 $190 $40 $63 4 $80 $320 $50 $240 $50 $60 5 $70...

  • Java code INNER PRODUCT 4E Input Standard input Output Standard output Topic Array & Array Processing!...

    Java code INNER PRODUCT 4E Input Standard input Output Standard output Topic Array & Array Processing! Problem Description The inner product (also known as the dot product or scalar product) of the elements of set A and the elements of set B of size is defined as the sum of the products of corresponding terms. For example, given set A as the array (2, 3, 4, 5, 6, 7, 8, 9; and set B as 6,5, 4, 3, 2, 7,...

  • Write a Java program to remove the duplicate elements of a given array and return the...

    Write a Java program to remove the duplicate elements of a given array and return the new length of the array. Sample array: [20, 20, 32, 76, 30, 40, 50, 50, 52] After removing the duplicate elements the program should return 6 as the new length of the array. Out put Original array length: 9 Array elements are: 20 20 32 76 30 40 50 50 52 The new length of the array is: 7

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