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
The practice of spamming has been growing because telephone solicitation is no longer legal. it is good advertising practice and
Ratling [72]

The given question is not a true or false question. It is a Multiple Choice question. By googling it you can find the correct question here https://www.coursehero.com/file/poq0d6/The-practice-of-spamming-has-been-growing-because-a-it-is-unregulated-b-it-is/

The practice of spamming has been growing because it is so inexpensive and can reach so many people.

Option: D.

<u>Explanation:</u>

Spamming is sending unsolicited messages which is mostly used to prank initially. Spamming has increased these days in various forms and platforms, Mainly in the marketing field, in the form of email, direct messages, etc, to advertise products.  

There are various tools that can send a message along with the sender's website or product links to multiple recipients. These tools are widely used in the spamming process. These tools require only a small amount of money either to buy a membership or to send the messages.

Moreover, most of the people around the world using smartphones have mail ids and smartphones have access to the Internet. Either 2 out of 5 people will get attracted to the message and visit the respective sender's site. That, in turn, builds traffic to the sender's site or makes the recipients buy the sender's product or services.

7 0
3 years ago
Use the writeln() method of the document object to display the current platform in a tag in the webpage. Hint: The platform prop
Allisa [31]

Using the knowledge in computational language in JAVA it is possible to write a code that the document object to display the current platform in a tag in the webpage

<h3>Writting the code in JAVA:</h3>

<em> <TABLE></em>

<em>      <ROWS> </em>

<em>      <TR> </em>

<em>      <TD>Shady Grove</TD></em>

<em>      <TD>Aeolian</TD> </em>

<em>      </TR> </em>

<em>      <TR></em>

<em>      <TD>Over the River, Charlie</TD></em>

<em>      <TD>Dorian</TD> </em>

<em>      </TR> </em>

<em>      </ROWS></em>

<em>      </TABLE></em>

<em>    </em>

<em />

See more about JAVA at brainly.com/question/12975450

#SPJ1

3 0
2 years ago
A group of interrelated resources acting together according to a plan to accomplish the goals of the records and information man
Verizon [17]

Answer: Record system

Explanation:

 The record system is one of the type of information storage system that stored all the records or data in the form of management system.

  • We can also retrieve the our data or information by saving it in the system so that we can use that specific data for future use.
  • It also helps in ensuring the data integrity and providing an efficient security to our data or information in the system.

 According to the given question, record system is one of the information management system that helps in accomplished the goals in the form of record.

 Therefore, Record system is the correct answer.

8 0
4 years ago
What can be done to reduce the occurrence of policy
natali 33 [55]
What can be done to reduce the occurence of policy?


5 0
4 years ago
Rockstar Software, Inc., develops a new series of performance-related video games. This software is most likely protected by
Nimfa-mama [501]
DRM likely is the answer. Anything that prevents duplication really.
6 0
4 years ago
Other questions:
  • An example of software is
    9·2 answers
  • "How has graphic design changed through time?"
    10·1 answer
  • The number of protons plus the number of nuetrons equal the <br> A.atomic weight<br> B.atomic number
    10·1 answer
  • What year did Elvis die? Right answer 1977.
    14·1 answer
  • What internet access technology currently uses a technology called 4G?
    13·1 answer
  • Which method of traversing a tree would result in a sorted list for a binary search tree?
    11·1 answer
  • Which of the following is true of e-learning and computer-based training (CBT)?
    13·1 answer
  • What is the output?
    11·2 answers
  • What are some limitations when it comes to testing and ensuring program quality? List at
    15·1 answer
  • if a user watches a video with event tracking three times in a single session, analytics will count how many unique events?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!