English

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: cfc5=f-329 - Computer Applications

Advertisements
Advertisements

Question

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` 

Answer in Brief

Solution

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
  Is there an error in this question or solution?
Chapter 3: Arrays (Single Dimensional and Double Dimensional) - EXERCISES [Page 240]

APPEARS IN

Avichal Computer Applications [English] Class 10 ICSE
Chapter 3 Arrays (Single Dimensional and Double Dimensional)
EXERCISES | Q VII. 2. | Page 240
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×