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
What is control structure write it's types​ .
MAXImum [283]

Answer

<u>Defination</u><u>-</u><u>:</u>

A control statement is a statement and a statement whose execution its control.

<u>Types-:</u>

  • Selection Statement
  • Iteration Statement
  • Unconditional branching Statement
4 0
3 years ago
You have implemented a network where hosts are assigned specific roles, such as for file sharing and printing. Other hosts acces
yulyashka [42]

<u>Client-server</u> implemented a network where hosts are assigned specific roles, such as for file sharing and printing. Other hosts access those resources but do not host services of their own.

<u>Explanation:</u>

The client-server can be utilized on the web just as on a neighborhood (LAN). Instances of customer server frameworks on the web incorporate internet browsers and web servers, FTP customers and servers, and the DNS. Different hosts get to those assets yet don't have administrations of their own. Since it permits arrange permits numerous PCs/gadgets to interface with each other and offer assets.

5 0
4 years ago
What is the serializable interface and what makes an object serializable?
Varvara68 [4.7K]

Answer: Serializable interface is the interface that acts as the maker persisting without any specific method and members in Java. The maker has the objective of identification of class for serialization method. This helps in the conversion of the object value in the byte form.

Object is serialized by converting the state into byte version and thus can be returned to object copy . The java.io.Serializable interface is the requirement for the conversion of any object of particular class or superclass. This technique is followed for making the data flow on the network efficient and easy.

5 0
4 years ago
What helps to identify trends?
vagabundo [1.1K]
Pie graph but idk if thats the answer
4 0
4 years ago
Read 2 more answers
Python please!
riadik2000 [5.3K]

We have that the output that frequency with the next 4 higher key <u>frequencies  </u>is <em>mathematically </em>given as

Output

  • 120,127,13,134.8,142,1,151.19

From the question we are told

  • On a piano, a key has a frequency, say f0.
  • Each higher key (black or white) has a frequency of f0 * rn, where n is the distance (number of keys) from that key, and r is 2(1/12).
  • Given an initial key <em>frequency</em>, output that <em>frequency</em> and the next 4 higher key <em>frequencies</em>.

Output each floating-point value with two digits after the decimal point, which can be achieved as follows:

<h3> Output and frequency</h3>

Generally the code will go as follows

# The key frequency

f0 = float(input())

r = math.pow(2, (1 / 12))

# The frequency, the next 4 higher key f's.

frequency1 = f0 * math.pow(r, 0)

frequency2 = f0 * math.pow(r, 1)

frequency3 = f0 * math.pow(r, 2)

frequency4 = f0 * math.pow(r, 3)

frequency5 = f0 * math.pow(r, 4)

# printing output

print('{:.2f} {:.2f} {:.2f} {:.2f} {:.2f}'.format(frequency1, frequency2, frequency3, frequency4, frequency5))

Therefore

Output

120,127,13,134.8,142,1,151.19

For more information on frequency visit

brainly.com/question/22568180

3 0
3 years ago
Other questions:
  • Your friend is working on fixing their Homework assignment. They need a lot of help. You know all the bugs in the file, but due
    12·1 answer
  • Consider an interface p ublic interface NumberFormatter { String format (in n); } Provide four classes that implement this inter
    15·1 answer
  • A​ client-server application that requires nothing more than a browser is called​ ________.
    8·2 answers
  • Write a C# program named InchesToCentimeters that declares a named constant that holds the number of centimeters in an inch: 2.5
    14·1 answer
  • Media applications that play audio or video files are part of a class of workkloads called "streaming" workloads (i.e., they bri
    9·1 answer
  • why when I click apostrophe I get an accent mark? And when I try quotation marks I get this ( ¨ ) how do I change that or why is
    13·1 answer
  • WILL MARK BRIAN PLZ HELP PLZ I BEG YOU While levels often change in order to give a game some more variability, they might also
    11·1 answer
  • Logo Game:name the 10 social media logos you see in the picture below​
    15·2 answers
  • 10
    14·2 answers
  • What is an example of new technology having a negative impact on sustainability?.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!