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
Travka [436]
3 years ago
8

Write a program that asks the user for two file names. The first file will be opened for input and the second file will be opene

d for output. (It will be assumed that the first file contains sentences that end with a period.) The program will read the contents of the first file and change all the letters to lowercase except the first letter of each sentence, which should be made uppercase. The revised contents should be stored in the second file.
Computers and Technology
1 answer:
Wewaii [24]3 years ago
5 0

Answer:

#include <iostream>

#include <fstream>

#include <string>

using namespace std;

int main()

{

//First we declare string variables to store file names for input and output

   string inputName;

   string outputName;

   string sentence;

// Then declare char variable to get current char

   char ch;

//The following section will prompt theuser to enter the file names and read

   cout << "Enter input file name:\n";

   cin >> inputName;

   cout << "Enter output file name:\n";

   cin >> outputName;

//ignore newline character left inside keyboard buffer

   cin.ignore();

//Next we define the input and output files to be opened

   ifstream inputFile(inputName);

   ofstream outputFile(outputName);

   if(!inputFile && !outputFile){

       cout << "Error while opening the files!\n";

       cout << "Please try again!\n";

       //end program immediately

       return 0;

   }

//Using this loop to get lines one by one, delimited by '.'

   while(getline(inputFile, sentence, '.')){

       //bool variable to store if we have already

       //printed capital first letter

       bool alreadyCapitalized = false;

       //Using of for loop on all characters of sentence

       for(int counter = 0; counter < sentence.length(); counter++){

           //if not alphabetical character,

           //so whitespace or newline, print as is

           if(!isalpha(sentence[counter]))

               outputFile << sentence[counter];

       //Condition statement for if it is alphabetical and no capitalization has been done, print it as uppercase

           if(!alreadyCapitalized && isalpha(sentence[counter])){

               outputFile << (char)toupper(sentence[counter]);

               alreadyCapitalized = true;

           }

           //otherwise print this condition as lowercase

           else if(alreadyCapitalized)

               outputFile << (char)tolower(sentence[counter]);

       }

       //Printing of the output sentence with period in the end

       outputFile << ".";

   }

   //Closing the files

   inputFile.close();

   outputFile.close();

   return 0;

}

You might be interested in
List two types of energy sources
makvit [3.9K]

Answer:

Types of energy sources include;

  • Geothermal energy
  • Solar energy
  • Wind power
  • Nuclear energy
  • Hydropower
  • Coal burning
  • Natural gas
  • Biomass energy
8 0
3 years ago
Read 2 more answers
To instruct Oracle11 g to sort data in ascending order, enter ____ after the column name in the ORDER BY clause.
Paha777 [63]

Answer:

A. ASC

Explanation:

In Oracle11 g ORDER BY clause is used to sort data andit is also used in mysql ,ms access.Though we not to mention ASC to sort in increasing order because by default it sorts the data in ascending order if we do not mention ASC or DESC.To sort in descending order we have to mention DESC.

So the correct answer to this question is ASC.

7 0
3 years ago
Read 2 more answers
An additional factor in how an element is rendered is that properties are passed from a parent element to its children in a proc
belka [17]

Answer:

style inheritance

Explanation:

What happens when a property on an element has no value supplied is governed by style inheritance. A property should inherit its value from its parent element, according to this specification.

6 0
2 years ago
lance measured 0.485 liter of water. Angel measured 0.5 liter of water. lance said, "My beaker has more water than yours because
nikdorinn [45]
No, if we were to make the decimal for angel it would be 0.500 which is more than lance, you can also round them
4 0
3 years ago
Read 2 more answers
¿por que la toria de lamarck sobre el alargamiento del cuello de las jirafas por el esfuerzo continuado no pasara a sus descendi
Paha777 [63]

Respuesta: Los caracteres adquiridos no se transmiten genéticamente porque no modifican el ADN de los organismos

Explicación:

Jean-Baptiste Lamarck al igual que Charles Darwin, propuso una teoría sobre la evolución que explicaba cambios en los organismos a través del tiempo. La teoría de Lamarck se enfocaba en condiciones en el ambiente que propiciaban cambios en los organismos. Un ejemplo de esto son las jirafas, que de acurdo a Lamarck tenían cuellos largos debido al esfuerzo continuado para comer hojas de árboles altos. Esto significa que la característica de cuello largo era adquirido por las jirafas durante su vida y según Lamarck se transmitiría a sus descendientes.

Sin embargo, se ha comprobado que los caracteres adquiridos no modifican el ADN de los organismos, por ejemplo las cirugías estéticas no cambian el ADN de una persona y por esta razón no son transmitidos a sus descendientes. Por el contrario, en las poblaciones de organismos ciertas características prevalencen en el tiempo debido a la selección natural. Esto significa que el cuello de las jirafas es el resultado que el cuello largo sea una característica beneficiosa que ha prevalecido debido a la selección natural y no de características adquiridas que son transmitidas a descendientes.

7 0
3 years ago
Other questions:
  • What are the People that make the goods called
    14·1 answer
  • To reboot a pc, hold down the ____ keys at the same time.
    15·1 answer
  • How do you determine which type of operating system that best supports your computer or mobile device?
    5·1 answer
  • Your organization network diagram is shown in the figure below. Your company has the class C address range of 199.11.33.0. You n
    8·1 answer
  • Difference between private and confidential data?​
    5·1 answer
  • Write a method called removeHighPrice that will go through a provided ArrayList called prices and removes the first price that i
    6·1 answer
  • Compare and contrast two fundamental security design principles in network security. Analyze how these principles and how they i
    15·1 answer
  • Reading (BCK FORM 2C IT 2020-2021)
    12·2 answers
  • In a word-processing program, what are the easily accessible icons that allow you to print, save and change fonts with a click o
    8·1 answer
  • How do you change your name on your brainly profile
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!