Answer:
import java.util.Arrays;
import java.util.Scanner;
public class num1 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter length of the array:");
int len = in.nextInt();
double [] temps = new double[len];
double avgTem;
int k =0;
double total = 0;
for( k=0; k<temps.length; k++){
System.out.println("Enter values for the array");
temps[k]=in.nextDouble();
}
System.out.println("The Arrays contains the following values");
System.out.println(Arrays.toString(temps));
// Computing the average of the values
for(k=0; k<temps.length; k++){
total = total+temps[k];
}
avgTem = total/(temps.length);
System.out.println("The average Temperature is: "+avgTem);
}
}
Explanation:
- Using Java programming language
- Import the Scanner class to receive user input
- Prompt User for the length of the Array, receive and store in a variable len;
- Declare a new double array of size len double [] temps = new double[len];
- Using a for loop, continually prompt user to enter values into the array
- Display the values of the array using Java's Arrays.toString method
- Use another for loop to add up all the elements in the arraay and store in the variable called total
- Outside the second for loop calculate the average avgTem = total/(temps.length);
- Display the average temp.
Answer:
10.
Explanation:
Binary search divides the array to be search each in half according to the value of the element.
The worst case time complexity of binary search is O(logN).
In this case the time complexity will come out to be log₂(1024)=10.
So the binary search can divide this array in half maximum of 10 times.
Hence the main loop will executes 10 times.
Answer:
hope this helps!
Explanation:
#include <iostream>
#include <fstream>
using namespace std;
void print_histogram(int counter[26])
{
for(int i = 0; i < 26; ++i){
cout << (char)(i+97) << " ";
for(int j = 0; j < counter[i]; ++j){
cout << (char)254;
}
cout << endl;
}
}
int main()
{
int counter[26] = {0};
string filename = "data.txt";
char byte = 0;
// opens file in read mode
ifstream input_file(filename);
if (!input_file.is_open()) {
cerr << "Could not open the file - '"
<< filename << "'" << endl;
return EXIT_FAILURE; // exit if not opened
}
// reads every character from the file
while(input_file.get(byte)){
if(byte >= 97 && byte <= 122){
++counter[byte-97];
}
}
print_histogram(counter); // required print histogram function
return 0;
}
Failure to lower the tilt-blocks or bed wedges when traveling locomotive cranes around curves will most likely result in damage to the crane, the splitting of the hoist lines, as well as the dropping of the load.
<h3>What is the most common cause of crane related fatalities?</h3>
A study has shown that the number of crane-related deaths is known to be a lot.
The main causes of worker deaths are said to be as a result of electrocution, collapse, and others.
Hence, Failure to lower the tilt-blocks or bed wedges when traveling locomotive cranes around curves will most likely result in damage to the crane, the splitting of the hoist lines, as well as the dropping of the load.
Learn more about cranes from
brainly.com/question/14765960
#SPJ1