Computer Science, asked by smrutiranibordhan600, 4 months ago

oad
2. Write a program in Java to store 20 temperatures in °F in a Single Dimensional Array
(SDA) and display all the temperatures after converting them into °C.
f - 32
5 9
and negative numbers
Hint: C/5= f-32 / 9

Answers

Answered by janvishewale256
2

Answer:

Write a program in Java to store 20 temperatures in °F in a Single Dimensional Array (SDA) and display all the temperatures after converting them into °C.

Hint: (c/5) = (f - 32) / 9

Java

Java Arrays

ICSE

4 Likes

ANSWER

import java.util.Scanner;

public class KboatSDAF2C

{

public static void main(String args[]) {

Scanner in = new Scanner(System.in);

double arr[] = new double[20];

System.out.println("Enter 20 temperatures in degree Fahrenheit");

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

arr[i] = in.nextDouble();

}

System.out.println("Temperatures in degree Celsius");

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

double tc = 5 * ((arr[i] - 32) / 9);

System.out.println(tc);

}

}

}

Similar questions