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
garri49 [273]
3 years ago
12

You do not need to use any functions beyond the main function in this problem. Initialize an array of int with the values: 4, 6,

9, and 12. Write a for loop to add the values in the array and find their sum. Write a second loop to print the values from the array and their sum in the following format: 4 6 9 12
Computers and Technology
1 answer:
zheka24 [161]3 years ago
4 0

Answer:

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

   

    int[] arr = {4, 6, 9, 12};

    int sum = 0;

   

    for(int i=0; i<arr.length; i++){

        sum += arr[i];

    }

   

    for(int i=0; i<arr.length; i++){

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

    }

    System.out.println("");

 System.out.println("The sum of the numbers: " + sum);

}

}

Explanation:

* The code is written in Java.

- Initialize the array with the given numbers

- Initialize the <em>sum</em> variable as zero

- Calculate the sum in the first for loop

- Print the numbers in the second for loop

- Print the <em>sum</em>

You might be interested in
Which of the following function declarations correctly expect an array as the first argument?
NARA [144]

Answer:

Only

Option: void f1(float array[], int size);

is valid.

Explanation:

To pass an array as argument in a function, the syntax should be as follows:

functionName (type arrayName[ ] )

We can't place the size of the array inside the array bracket (arrayName[100]) as this will give a syntax error. The empty bracket [] is required to tell the program that the value that passed as the argument is an array and differentiate it from other type of value.

3 0
3 years ago
Does two core processors mean that it is twice as fast do you agree? why?
vlabodo [156]

Answer:

the friendships the following link and fill out our related information

Explanation:

consisting of a new one of the cell number of people who want

3 0
2 years ago
his exercise creates a program to convert the temperature values form Fahrenheit to Celsius for a list of 10 temperature values
MissTica

Answer:

def fahrenheit_to_celsius(temperature):

   c = (temperature - 32) / 1.8

   return c    

temperature_list = [-10, -5, 0, 10, 20, 32, 40, 50, 60, 75.2]

i = 0

while i < 10:

   print(str(temperature_list[i]) + " degrees Fahrenheit = " + str(fahrenheit_to_celsius(temperature_list[i])) + " degrees Celsius")

   i += 1

Explanation:

*The code is in Python.

Create a function named fahrenheit_to_celsius that takes one parameter, temperature

Convert the temperature to celsius using the formula

Return the result of the conversion

Create a list holding ten temperatures

Create a while loop that iterates 10 times. Inside the loop, call the function to convert the each temperature in the list and print the result

5 0
3 years ago
Pat is listing the parts of a computer. Which is the best option to use when formatting the list?
Zina [86]
If you mean a web page ten the bet option would be elements, where gives you an unordered list and give you an order list
5 0
3 years ago
Write a program to play an automated game of Rock, Paper, Scissors. Two players make one of three hand signals at the same time.
zhuklara [117]

Answer:https://www.chegg.com/homework-help/questions-and-answers/program-specifications-write-program-play-automated-game-rock-paper-scissors-two-players-m-q84530098

3 0
2 years ago
Other questions:
  • What is the purpose of the chart feature in word?
    15·1 answer
  • What determines how large the crystals in an igneous rock will be?
    15·2 answers
  • Discuss whether the redundant data should be addressed prior to beginning the wireless network architecture project, in coordina
    11·1 answer
  • What is the reasoning you would write an inquiry to a company?
    5·2 answers
  • What are the network topologies? Advantages and disadvantages.
    9·1 answer
  • 13. A 2-sided coin has an equal likelihood of landing on each side. One side is called "heads" and the other is called "tails".
    11·1 answer
  • Hello can you please help with this if you want to thank you!
    15·2 answers
  • Which of the following is NOT a possible combination of values of the variables in this program when it finishes running?
    6·2 answers
  • ...............is a personal computer that fits on desk.​
    5·2 answers
  • Look at the code in the example below, and then answer the question.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!