1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Anon25 [30]
3 years ago
14

Number Analysis Program: Write a program that reads data from the text file numbers.txt. Assume the file contains a series of nu

mbers, each written on a separate line. The program should read the numbers from the file and store them into the array numbers. Then program should display the lowest value, the highest value in the array. Also calculate and display the average of these values.
Computers and Technology
1 answer:
diamong [38]3 years ago
8 0

Answer:

See Explaination

Explanation:

#include <iostream>

#include <fstream>

#include <string>

#include <iomanip>

// namespace std

using namespace std;

// start of the main function

int main() {

// setting precision to 2 decimal point

cout << fixed << setprecision(2) << endl;

// variable declration

int i, count = 0;

int min, max, value, arr[100];

double sum = 0;

double Avg;

// file object creation

ifstream infile;

string file;

// input the file name to read

cout << "Please enter the name of the file to read numbers for Number "

"Analysis program "

<< endl;

getline(cin, file);

infile.open(file.c_str());

// check if file exist or not

// and loop untill you get correct file name

// if you do not want to loop again and again then

// simply return 0; from code

if (infile.fail()) {

cout << "Error opening the file." << endl;

return 0;

// cout << "Please enter the name of the file to read numbers for Number "

// "Analysis program "

// << endl;

// getline(cin, file);

// infile.open(file.c_str());

}

// start reading the data from the file

while (infile >> value) {

arr[count] = value;

count++;

}

// initialize min max to arr[0]

min = max = arr[0];

// find the lowest element

for (i = 0; i < count; i++) {

if (arr[i] < min) {

min = arr[i];

}

}

for (i = 0; i < count; i++) {

// find the highest element

if (arr[i] > max) {

max = arr[i];

}

}

for (i = 0; i < count; i++) {

// calculate sum

sum = sum + arr[i];

}

Avg = sum / count;

// display output

cout << "The highest value is " << max << endl;

cout << "The lowest value is " << min << endl;

cout << "The sum of the numbers is " << sum << endl;

cout << endl;

cout << "The average of the numbers is " << Avg << endl;

return 0;

} // end of the main program

You might be interested in
You designed a program to create a username using the first three letters from the first name and the first four letters of the
Pavel [41]

Answer:

See Explanation

Explanation:

The question would be best answered if there are options to select from; since none is provided, I will provide a general explanation.

From the question, we understand that, you are to test for Jo Wen.

Testing your program with this name will crash the program, because Jo has 2 letters (3 letters are required), and Wen has 3 letters (4 letters are required)

So, the step that needs to be revisited is when the username is generated.

Since the person's name cannot be changed and such person will not be prevented from registering on the platform, you need to create a dynamic process that handles names whose lengths are not up to the required length.

7 0
3 years ago
How does a Cloud-first strategy differ from other approaches to Cloud?
Brut [27]

Answer:

There is a considerable difference between a cloud-first strategy and other cloud approaches. The developers of the cloud-first strategy are familiar of every data point that requires backup and synchronization. As a result, a lower assembly layout that is more tolerant of database sync is required. In other words, a cloud-first strategy can easily accommodate new technology.

Cloud-first strategy is the current data management method that was not available a few years ago. Such processes and reliability are inapplicable when transferring application software and data to the cloud. You will have to make sacrifices in terms of load balancing and distributed functionality, which will be limited when using other cloud approaches. And this is where Cloud-first strategy shines, as you will be able to control and use all of the host's functionalities.

Explanation:

A cloud-first strategy is one in which all or most of an organization's structure is moved to a cloud-computing environment. Traditionally, organizations required physical supplies to keep their online data; nowadays, they store it on the cloud, which is fundamentally more useful. Cloud-first organizations, regardless of size or importance, are designed to operate their operations on cloud servers. Rather of transferring the organization's data and services to the cloud, adopt a cloud-first strategy and design the application software from the ground up. Not only does the cloud-first strategy outperform traditional application architectures in terms of performance, but it also provides higher stability.

5 0
1 year ago
President Roosevelt's Fireside Chats were:
larisa86 [58]
C. Entertaining radio shows that families listened to in the evening. He did these chats to inform the public on what he was going to do about the problems facing the public.
3 0
3 years ago
Read 2 more answers
1. Data in a smart card can be erased
Ostrovityanka [42]

Answer:

false

true

false

true

true

5 0
3 years ago
Read 2 more answers
the two main forces acting on a computer that sits on a table are _________ and _________. a. weight; gravity b. weight; mass c.
EleoNora [17]
It is A.weight: gravity
8 0
3 years ago
Read 2 more answers
Other questions:
  • How is sharepoint used in organization today?
    12·1 answer
  • What type of rain happens when cold air meets warm air
    14·1 answer
  • To reduce inflation, the Federal Reserve _____ the money supply. This action also causes the economy to shrink.
    13·2 answers
  • When activated, an Excel object has all the features of an Excel
    8·2 answers
  • The moon has less mass than the earth, so what happens to objects on the moon?
    11·1 answer
  • If you want to conserve ink or toner, you can instruct powerpoint to print ____ documents.
    6·1 answer
  • Which is a benefit of using the paste link option?
    15·2 answers
  • Which element is represented by the electron configuration in example B? Example B: 1s22s22p63s23p64s1 Aluminum Cesium Potassium
    12·2 answers
  • What are acenders? What are decenders?
    10·2 answers
  • Instructions: Write a program that calculates the amount of ingredients needed for various flavors of cheesecake.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!