Bright Tutorials LogoBright Tutorials
SolutionsQ&AQuestion BankCoursesDownloadsBlogAboutVideosEnquiry
Bright Tutorials LogoBright Tutorials
LoginSign Up
Bright Tutorials LogoBright Tutorials

Your partner in achieving academic excellence in Nasik.

Quick Links

  • About Us
  • Textbook Solutions
  • Q&A Forum
  • Offline Classes
  • Video Library

Contact Us

Bright Tutorials
401 Vinit Height, Durga Nagar,
Bhavani Nagar, Nasik Road, Nashik
Maharashtra - 422101

Phone: 9403781999

WhatsApp: 9404781990

Stay Updated

Subscribe to our newsletter for the latest updates.

© 2025 Bright Tutorials. All rights reserved.

    1. Q&A Forum
    2. Write a program in java to store 20 temperatures in F in a single dim array (SDA) and display all temperatures after converting them in to C Hint (c/5)=(f-32)/9

    Write a program in java to store 20 temperatures in F in a single dim array (SDA) and display all temperatures after converting them in to C Hint (c/5)=(f-32)/9

    Asked by tusharparik • about 2 months ago

    Write a program in java to store 20 temperatures in F in a single dim array (SDA) and display all temperatures after converting them in to C Hint (c/5)=(f-32)/9

    Answers

    admin
    about 2 months ago
    ```html

    Java Program to Convert Fahrenheit Temperatures to Celsius

    Here is a Java program that stores 20 temperatures in Fahrenheit in a single-dimensional array and then displays them after converting them to Celsius.

    Java Code

    public class TemperatureConverter {
    public static void main(String[] args) {
    // Array to store 20 temperatures in Fahrenheit
    double[] fahrenheitTemperatures = new double[20];

    // Example: Initialize with some Fahrenheit values
    for (int i = 0; i < fahrenheitTemperatures.length; i++) {
    fahrenheitTemperatures[i] = 68 + i * 2; // Example values
    }

    // Convert and display temperatures
    System.out.println("Fahrenheit\tCelsius");
    for (double fahrenheit : fahrenheitTemperatures) {
    double celsius = (5.0 / 9.0) * (fahrenheit - 32);
    System.out.println(fahrenheit + "\t\t" + celsius);
    }
    }
    }

    Explanation

    1. Declare and Initialize the Array:
      A double array `fahrenheitTemperatures` is created to store 20 Fahrenheit temperatures. Example values are assigned to it using a loop.
    2. Conversion and Display:
      The program iterates through the `fahrenheitTemperatures` array. For each Fahrenheit value, it calculates the equivalent Celsius value using the formula:
      Celsius = (5.0 / 9.0) * (Fahrenheit - 32)
      The Fahrenheit and Celsius temperatures are then printed.

    This program initializes the Fahrenheit temperatures with example values. You can modify it to take input from the user or read from a file.

    ```

    Your Answer

    Loading...