Ask Question

The common field cricket chirps in direct proportion to the current temperature. Adding 40 to the number of times a cricket chirps in a minute, then dividing by 4, gives us the temperature (in Fahrenheit degrees). Write a program that accepts as input the number of cricket chirps in fifteen seconds, then outputs the current temperature

+1
Answers (1)
  1. 13 December, 18:32
    0
    This program is written in Java programming language;

    First, you should understand that:

    The formula given in the question implies that the current temperature can only be calculated using measurement of time in minutes;

    Given that the number of chirps is directly proportional to the temperature.

    If the cricket made n chirps in 15 seconds, it will make n * (60/15) chirps in 1 minutes;

    n * (60/15) = n * 4

    Base on this analysis, the program is as follows

    import java. util.*;

    public class cricket

    {

    public static void main (String []args)

    {

    //Declare number of chips in 1 minutes

    int num;

    Scanner input = new Scanner (System. in);

    //Prompt user for input

    System. out. print ("Number of chirps (in 15 seconds) : ");

    num = input. nextInt ();

    //Calculate temperature (multiply temperature by 4 to get number of chirps in minutes

    double temp = (num * 4 + 40) / 4;

    //Print temperature

    System. out. print ("Current Temperature = "+temp+" F");

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “The common field cricket chirps in direct proportion to the current temperature. Adding 40 to the number of times a cricket chirps in a ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers