using an array write a program that will ask the user to enter a temperature for each day of the week and will find and print the average temperature, the low temperature and high temperature In Java
The approach and program to find the highest, lowest and the average temperature of a week by using arrays is given below:
Approach:
Code:
//importing the package
import java.util.*;
//declaring the main class
public class Main
{
//declaring the main function
public static void main(String[] args)
{
//creating the object of Scanner class
Scanner input = new Scanner( System.in );
//declaring the array
double t [];
//allocating memory to the array
t = new double[7];
//declaring the variables as per the requirement
//initializing the variables to zero
double s = 0;
double avg_temp = 0;
System.out.println("Please enter the temperature for each day: ");
//for loop is used to check the condition repeatedely
for( int i = 0; i < 7; i++ )
{
//prompt user to take input
System.out.print("Temperature of day " + ( i + 1 ) + ":" );
t[i] = input.nextDouble();
//sum of temperature
s = s + t[i];
//calculating the average
avg_temp = s / t.length;
}
//calculating the average
avg_temp = s / t.length;
&...
Q: a. Explain what the CPU should do when an interrupt occurs. Include in your answer the method the CP...
A: Method used by Central Processing Unit (CPU) while an interrupt occursThe CPU first checks and then ...
Q: (check all that apply) Find all the employees located in DallasA) select ename from dept where loc =...
A: Checking all the given SQL query to find all the employees located in dallas,Creating table from the...
Q: In MS Access, which kind of values will be accepted by the databasethrough input mask>L0L0L0;0;#A...
A: An input mask in MS-Access contain 3 fields.These fields are separated by semi-colonFirst field spec...
Q: How do I code this on python heres the problem Use the Design Recipe to define a function count_val...
A: Programming instructions: Define the function count_value which takes the list and a value as an arg...
Q: in c++ Given the following, use a range-based for loop to load the array with user input (include a ...
A: The C++ program to enter and display the content of an integer array by using range-based for loop, ...
Q: Find the location that has average salary more than 4000 dollars. Usually each location mayhave seve...
A: SubqueryA subquery is a query within another query. A subquery is a query that is embedded in WHERE ...
Q: Explain why web application security is vital. What could happen to an insecure application? Why is ...
A: Web application securityWeb application security testing ensures that the information system is capa...
Q: Given the follwing business rules, create an ERD. The ERD must include all primary keys, foreign ke...
A: The entities, primary keys and foreign keys and attributes of ERD are:
Q: List and describe four vulnerability intelligence sources. Which seems the most effective? Why?
A: Sources of Vulnerability IntelligenceSecurity VendorsSoftware VendorsGovernment and public organizat...