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]
2 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]2 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
More registers appear to be a good thing, in terms of reducing the total number of memory accesses a program might require. Give
gulaghasi [49]

Answer:

Following is given the answer step by step:

Explanation:

First of all we will write a program using MARIE that will support the statement: Sum = (A + B) - (C + D). All the necessary comments are given in front of each statement:

Load    A                   # variable A will be loaded

Add     B                  # B will be added to A

Store   Temp1         # A + B will be stored in Temp1

Load    C                  # C will be loaded in memory

Add     D                 # D will be added to C

Store   Temp2         # C + D will ge stored in Temp2

Load    Temp1         # Temp1 will be loaded in the memory

Subt     Temp2         # Temp2(A + B) get subtracted from Temp1(A - B)

Store    Sum             # (A + B) - (C + D) will get stored in Sum.

We can see from above program that memory is accessed 9 times. While if C + D get executed first than memory accesses will be reduced to 7.

Above same program could be written using an architecture of 4 registers:

  • R1
  • R2
  • R3
  • R4

The program is as follows:

Load   R1 , A     #A  will be loaded into R1

Load   R2 , B    # B will be loaded into R2

Add     R1 , R2    # R2 gets added to R1 and the result is stored in R1 (A + B)

Load   R3 , C      # C loaded into R3

Load   R4 , D     # D loaded into R4

Add    R3 , R4   # Value in R4 gets added into R3 and R3 becomes (C + D)

                          #no memory accesses required for this operation

Subt   R1 , R4     #R4 (C + D) gets subtracted from R1 (A + B)

                         #no memory accesses required for this operation

Store  Sum        # The recent value will be stored into Sum

Here memory is accessed 5 times in total.

<h2>I hope it will help you!</h2>
8 0
2 years ago
The parts of a memo are _____.
Alex
The correct answer would be D
4 0
3 years ago
Read 2 more answers
Gigano Mobiles, a smartphone manufacturer, is going to release its new flagship device next month. The Chief Executive Officer (
ser-zykov [4K]

Answer:

trhrt

Explanation:

rhshnbbfsfhnsdfbhddbh

7 0
3 years ago
Describe your dreams include lifestyle,job,house,friends
n200080 [17]
So, this is an answer of your choice. What it is trying to ask is tell us what your dream home, job, husband, and so on. For example: My dream home is a mansion in Mississippi by the beach. My dream job is a doctor. Those are prime examples of a dream home and job. Now your answer shouldn't be the same as mine. Your's should be something different. Unless, you want a mansion in Mississippi by the beach and you would like to be a doctor. In other words it is asking you to tell us what you want you home, lifestyle, job, friends, and possibly your DREAM pet. Hope this helps.

3 0
2 years ago
Read 2 more answers
Write the name of the tab, command group, and icon you need to use to access the borders and shading dialog box.
Ilia_Sergeevich [38]

Answer:

Tab: Home Tab

Command group: Paragraph

Icon: Triangle

Explanation:

7 0
3 years ago
Other questions:
  • To apply the rule of thirds you first? PLZ HURRY AND ANSWER THIS
    5·2 answers
  • Assume the existence of a class named window with functions named close and freeresources, both of which accept no parameters an
    13·1 answer
  • Every time you are asked to work with others, you are being asked to:
    6·2 answers
  • What is the term for sending emails that imitate legitimate companies?
    6·2 answers
  • How was windows 3 installed on a pc?
    11·1 answer
  • The network architecture component that is a special LAN with a group of servers that enables electronic data exchange of betwee
    8·1 answer
  • Several NEC® sections contain the requirement to size conductors and overcurrent devices at 100 percent of the noncontinuous loa
    15·1 answer
  • By limiting the number of times a person can use a type of software before registering as the authorized owner of that software,
    15·1 answer
  • Which generation of computer is most popular and why?
    9·1 answer
  • A company is completing research and development for software which it is planning to produce in approximately 2 years time. Whi
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!