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
Lerok [7]
3 years ago
6

C++ coding, help

Computers and Technology
1 answer:
Zanzabum3 years ago
4 0

Answer:

The program in C++ is as follows:

#include <fstream>

#include <iostream>

#include <iomanip>

using namespace std;

int main() {

 string filename;

 cout<<"Filename: ";

 cin>>filename;

 ifstream inFile(filename);

 if(!inFile) {

   cout << endl << "Cannot open file " << filename;

   return 1;  }  

 ofstream fout;

 ifstream fin;

 fin.open("invalid-numbers.txt");  

 fout.open ("invalid-numbers.txt",ios::app);  

 double sum = 0; int valid = 0; int invalid = 0;

 double num = 0;

 while(!inFile.eof()) {

   inFile >> num;

   if(num >= 0 && num<=110){   sum+=num; valid++; }

else{ invalid++;

if(fin.is_open()){

   fout<<fixed<<setprecision(2)<<num<<"\n";    }  }  }

 fin.close();

 fout.close();

 inFile.close();

 cout<<"Total values: "<<valid+invalid<<endl;

 cout<<"Invalid values: "<<invalid<<endl;

 cout<<"Valid values: "<<valid<<endl;

 cout<<"Average of valid values: "<<fixed<<setprecision(2)<<sum/valid<<endl;    

 double inv;

 ifstream inFiles("invalid-numbers.txt");

 while(!inFiles.eof()) {

   inFiles >> inv;

   cout<<inv<<"\n";

}

inFiles.close();

 return 0;

}

Explanation:

See attachment for source file where comments are used to explain each line

Download cpp
You might be interested in
The view that perceptual processes take place over time and can be thought of in terms of a software/hardware metaphor is known
Wittaler [7]

The view that perpetual processes can be thought of in terms of a software/hardware metaphor is known as the: information processing view.

<h3>What is the Information Processing View?</h3>

Information processing view is explained by the cognitive theory to explain how the brain encodes information and how information are filtered from what we pay attention to in a particular moment. This also determines what is stored in the short-term or in our long-term memory.

Therefore, the view that perpetual processes can be thought of in terms of a software/hardware metaphor is known as the: information processing view.

Learn more about the information processing view on:

brainly.com/question/24863946

3 0
2 years ago
To run a PHP application that has been deployed on your own computer you can enter a URL in the address bar of your browser that
svet-max [94.6K]

Answer:

You can enter a URL that (B) Uses localhost as the domain name

Explanation:

Localhost refers to your computer or the computer that is currently in use.

To run a PHP application that is deployed on your computer, the localhost (which has an IP address of 127.0.0.1) is used.

The IP address is called a "loopback" address because all data sent or received revolve around the local computer.

8 0
4 years ago
The _____ option will allow a user to remove text from one location and keep it for use later on the clipboard.
ValentinkaMS [17]

I believe the answer is the "cut" option?

8 0
3 years ago
The technique of ________ uses three columns that allows the entrepreneur to weigh both the advantages and the disadvantages of
Mekhanik [1.2K]
Force-field analysis
5 0
3 years ago
The field on which records are sorted is called the composite primary key.A. TrueB. False
Gemiola [76]

Answer: TRUE

Explanation: Composite is simply used to refer to the existence of more than one event or pattern. The composite primary key as related to database management query refers to the synergy or combination of more than one field or column of a specified table which is used in sorting or accurate identification of a record. When attributes are combined, that is more than one, it assists in narrowing down the returned records such that records which are close and exclusive to the options specified are returned. Usually, the more the number of columns which makes uo the case mpoaite keys, the more unique and well sorted our returned output is.

4 0
4 years ago
Other questions:
  • Whats the difference between copying a file to my desktop and creating a shortcut?
    8·1 answer
  • Which career path includes the work duties of hiring and managing farm laborers?
    6·2 answers
  • Which of the following works on the pay-per-click (PPC) and cost-per-click (CPC) concept? ~ Plato
    9·1 answer
  • What are the benefits of building redundancy into a network?
    12·1 answer
  • Can someone please help me to point out what's wrong with this C program:
    13·1 answer
  • Determine the following information about each value in a list of positive integers.
    14·1 answer
  • 4. In paragraph 7, what is the meaning of the phrase "not
    13·1 answer
  • What's the maximum number of ad extensions that can show for a particular query or device at any given time?
    13·1 answer
  • You can use tables for layout work. However, in XHTML, each form control should have its own ______ element
    12·1 answer
  • Which is a monthly cost associated with renting a house?
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!