Advertisements
Advertisements
प्रश्न
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`
संक्षेप में उत्तर
उत्तर
import java.util.*;
public class AQ2
{ public static void main(String[] jp){
Scanner ob = new Scanner(System.in);
float f[] = new float[2], c[] = new float[2];
System.out.println("Enter the temperatures");
// INPUT AND CONVERSION
for (int = 0; i < f.length; i++)
{f[i} = ob.nextFloat();
c[i] = (float) (5.0 / 9) * (f[i] − 32);
}
// OUTPUT
System.out.println("***Temperatures Converted to Celsius");
for (int j = 0; j < c.length; j++)
System.out.println(c[j]);
}}
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?