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
GalinKa [24]
4 years ago
14

Create an array of doubles with 5 elements. In the array prompt the user to enter 5 temperature values (in degree Fahrenheit). D

o this within main. Create a user defined function called convert2Cels. This function will not return any values to main with a return statement. It should have parameters that include the temperature array and the number of elements. The function should convert the values for Fahrenheit to Celsius and save them back into the same array. Celsius=(F-32)*5/9 From main, print the modified temperature array in a single column format similar to one shown below: Temperatures(Celsius) 37.78 65.56 100.00 0.00 21.11 Test your program with the following values: 100 150 212 32 70
Computers and Technology
1 answer:
dalvyx [7]4 years ago
8 0

Answer:

The solution code is written in Java.

  1. import java.util.Scanner;
  2. public class Main {
  3.    public static void main(String[] args) {
  4.        double myArray [] = new double[5];
  5.        Scanner reader = new Scanner(System.in);
  6.        for(int i=0; i < myArray.length; i++){
  7.            System.out.print("Enter temperature (Fahrenheit): ");
  8.            myArray[i] = reader.nextDouble();
  9.        }
  10.        convert2Cels(myArray, 5);
  11.        for(int j = 0; j < myArray.length; j++){
  12.            System.out.format("%.2f \n", myArray[j]);
  13.        }
  14.    }
  15.    public static void convert2Cels(double [] tempArray, int n){
  16.        for(int i = 0; i < n; i++){
  17.            tempArray[i] = (tempArray[i] - 32) * 5 / 9;
  18.        }
  19.    }
  20. }

Explanation:

Firstly, let's create a double-type array with 5 elements, <em>myArray </em>(Line 6).

Next, we create a Java Scanner object to read user input for the temperature (8).

Using a for-loop that repeats iteration for 5 times, prompt user to input temperature in Fahrenheit unit and assign it as the value of current element of the array. (Line 11 - 12). Please note the nextDouble() method is used to read user input as the data type of input temperature is expect in decimal format.

At this stage, we are ready to create the required function convert2Cels() that takes two input arguments, the temperature array,  <em>tempArray</em> and number of array elements, <em>n </em>(Line 23).  Using a for-loop to traverse each element of the tempArray and apply the formula to convert the fahrenheit to celcius.  

Next, we call the function <em>convert2Cels() i</em>n the main program (Line 15) and print out the temperature (in celsius) in one single column (Line 17-19). The <em>%.2f</em> in the print statement is to display the temperature value with 2 decimal places.

You might be interested in
4. UPS stands for Uninterrupted Power Supply . (Yes /no
ser-zykov [4K]

Answer:

4)true

5)no(not good for computer )

6)easy

4 0
3 years ago
Why should you not remove a program by deleting its folder?
igomit [66]

Answer:

for the first six members in the series of alkenes plot the number of hydrogen atoms on they exist in use this number the graph to drive the formula of alkane that has 10 carbon atoms. i will give brain list

6 0
3 years ago
What is the predecessor for the internet??
Gennadij [26K]
The predecessor for the Internet is ARPANET . ARPANET was developed under the direction of the U.S. Advanced Research Projects Agency (ARPA) and first published in 1967.It was <span>designed to facilitate communication between ARPA computer terminals .</span>This network was the first fully operational packet-switching network.
4 0
3 years ago
Zander is beginning to take college courses to prepare for a career in computer science, which is the study of using logic to cr
scoundrel [369]

The answer is (A. career definition and career requirements  )


7 0
3 years ago
What is the scope of each variable?
kari74 [83]

Answer:

scope of pet name is limited to pet class and color is accessible to the whole program

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • Information gathered from observing a plant grow 3 cm over a two-week period results in _______.a. inferences. b. variables. c.
    11·1 answer
  • 1.2 Discuss each of the following terms: (a) data (b) database (c) database management system (d) database application program (
    12·1 answer
  • Can you give me a long list of kid's cartoons
    15·1 answer
  • Shipments of compact digital cameras dropped by 42% due to the industry being unable to adjust to changes in the ________. a. ec
    11·1 answer
  • Is a tv a
    6·1 answer
  • Read the integer numbers in the text file "1000 Random Number from 0 to 100.txt" into a list
    6·1 answer
  • In 2 or 3 sentences, describe one advanced stradegy and how its useful
    11·1 answer
  • If my usb could unlock my computer with a tool then could i be able to open it using ip unlock
    9·1 answer
  • Which of the following correctly stores 45 squared in the variable x?
    11·1 answer
  • Which reports indicate how traffic arrived at a website?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!