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
Create a java program using the following instructions:GymsRUs has a need to provide fitness/health information to their clients
poizon [28]

Answer:

See attached file for detailed code.

Explanation:

See attached file for explanation.

Download txt
8 0
4 years ago
What does every shot have with regards to depth?
djyliett [7]

This can be used to capture a larger area of acceptably sharp images. This can also be referred to as a deep depth of field, and some cinematographers will simply use the term “depth” to describe shots with a large DOF. It can also be referred to as deep focus.
5 0
3 years ago
What does the binary code 01101000 01100101 01101100 01101100 01101111 00100000 01101101 01111001 00100000 01100110 01110010 011
BigorU [14]

Answer:

hello my friend

6 0
3 years ago
Read 2 more answers
The grade of a metric bolt is designated by
Andre45 [30]
The answer to your question is The grade of a metric bolt is designated by the number stamped on the head of the bolt.
5 0
3 years ago
When researching using the internet, you should always ensure that the information you find on a website is ________.
Schach [20]

The answer is the last choice, "Credible."


Fun and entertaining websites are good for your personal time, but not for research. Persuasive websites may seem convincing, but usually persuade through emotions rather than facts. Therefore, you should make sure the information/website is credible and is supported by facts and reliable individuals.

4 0
4 years ago
Other questions:
  • Read the scenario, A manager wants to hire a new technician for the help desk that typically assists clients with simple compute
    10·1 answer
  • Once I have entered text into a presentation, how do I modify the font style of the text? Select the text and use options availa
    9·2 answers
  • 3. The combination of keys that we should press to select all document is
    14·1 answer
  • Gloria is in her sophomore year of college and works part time. She has assignments saved on her home computer, her aunt's lapto
    6·2 answers
  • Ellen's laptop has a built-in 802.11n-capable wireless NIC. The wireless NIC worked perfectly yesterday when she loaned it to he
    12·1 answer
  • var shirt = "blue"; 2. var pants = "gray"; 3. var clothes = wearIt(shirt, pants); 4. function wearIt( x, y) 5. { 6. var myOutfit
    7·1 answer
  • By
    7·1 answer
  • Recent advances in information technologies (IT) have powered the merger of online and offline retail channels into one single p
    10·1 answer
  • When was "Rick Astley Never Gonna Give You Up" originally made?
    6·2 answers
  • missy just hired a software development team to create an educational simulation app for a high school course. she has specific
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!