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
Which of the following is a beneficial reason to extract mineral resources from the earth?
Nata [24]

Answer:

2, It increases surface runoff

5 0
4 years ago
Read 2 more answers
What kind of problems could you run into if you format a cell with the wrong format for the data type?
exis [7]
The answer to the following question

<span>What kind of problems could you run into if you format a cell with the wrong format for the data type?

is:

there is a great possibility that your file format won't open because it has the wrong format</span>
8 0
3 years ago
Read 2 more answers
Bluetooth is the popular name for the 802. 15 wireless networking standard, which is useful for creating small __________.
astra-53 [7]

Answer:

Personal Area Networks (PANs).

8 0
1 year ago
Managing your calendar and emails can be easily accomplished through ___ software
r-ruslan [8.4K]
<span>Managing your calendar and emails can be easily accomplished through personal information management software.
These types of software can deal with your personal information, such as meetings, calendar appointments, etc. 
</span>
6 0
3 years ago
Write the definition of a class employee base on the modular specification: . A data member for Id of type int (private). A data
djyliett [7]

Answer:

public class Employee {

   private int id;

   private String empName;

   private double salary;

   

   public void displayEmployee(){

       System.out.print("Employee ID: " + id + "\nEmployee name: " + empName + "\nSalary: " + salary);

   }

}

Explanation:

- Declare the class variables

- Write a method called <em>displayEmployee</em> to display the fields

7 0
3 years ago
Other questions:
  • You can create a database using one of the many templates available or by creating a new ______ database.
    9·1 answer
  • Instructions Write a program that asks the user for a number. If the number is between 1 and 255, the program outputs the corres
    15·1 answer
  • Which one of the following characteristics or skills of a ScrumMaster are closelyaligned with coaching?Select one:
    5·1 answer
  • What is infinite recursion?
    7·1 answer
  • A cybersecurity analyst is currently investigating a server outage. The analyst has discovered the following value was entered f
    9·1 answer
  • Which of the following illustrations is depicted in the icon that's used to access Windows Help and Support files?
    13·1 answer
  • When adopting the use of social media in emergency management, it is important to have
    10·1 answer
  • It is a blueprint of a project​
    9·2 answers
  • Write an algorithm to verify a number as even​
    9·1 answer
  • Array bounds checking should be directly coded into a system rather than assumed.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!