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
The type of power that has the ability to call on connections and networks both inside and outside the organization for support
givi [52]

Answer: c) Connection power

Explanation:

Connection power is the power that is established personally in the field of business.A person having connection with powerful person personally outside or inside the organizational field then he/she can attain the desired goals or result through connecting with them, influencing powerful person's decision, getting their things done etc .

  • Other options are incorrect because association power, information power,coercive power and referent power are the power to establish connection organization to achieved aim.
  • Thus, the correct option is option(c)
5 0
3 years ago
* what is an electronic mail ?
Vikki [24]

Answer:

Electronic mail is a method of exchanging messages between people using electronic devices. Email entered limited use in the 1960s, but users could only send to users of the same computer, and some early email systems required the author and the recipient to both be online simultaneously, similar to instant messaging.

6 0
3 years ago
CHALLENGE
Lorico [155]

Answer:

Following are the program to this question:

#include <stdio.h>//using the header file

int main()//main method

{

int y;//defining integer variable y

printf("Enter year value:");//print message

scanf("%d", &y);//use input method for input year value

if (y>= 2101)//defining if block that checks year greater then 2101

   printf("Distant future");//print message

else if (y>= 2001)//defining else if block that checks year greater then 2001

   printf("21st century"); //print message

else if (y>= 1901)//defining else if block that checks year greater then 1901

   printf("20th century");//print message

else  //defining else block

   printf("Long ago");//print message

   return 0;

}

Output:

Enter year value:1998

20th century

Explanation:

In the given C language code, inside the main method, an integer variable "y" is defined, which allows the user to input the year value, and use the multiple conditions to check the given value and print message when the condition is matched.  

  • Inside the "if" condition block, it checks the "y" variable value is greater and equal to 2101. so, it will print "Distant future", otherwise go to the next condition.
  • In this, if "y" value is greater than equal to "2001", it will print the message "21st century", otherwise go to the next condition.  
  • In this, If the value of "y" is greater than equal to "1901", it will print the message "20th century", and if all the above condition is not true, then it will go to the else block, and it will print "Long ago" as the message.
6 0
3 years ago
Draw a flowchart to convert 5 kg into gram .​
dlinn [17]

Answer:

Kg to g, multiply by 1000

Therefore, 5 Kg = 5000 gms

Explanation:

5 0
3 years ago
Read 2 more answers
Which is many many years of vot in nepal.​
Butoxors [25]

Answer:

18 yrs

Explanation:

3 0
3 years ago
Other questions:
  • Write a recursive method public static String reverse(String str) that computes the reverse of a string. For example, reverse("f
    6·1 answer
  • What type of media can be edited and published by anyone?
    6·2 answers
  • The use of computers in education is referred to as computer-assisted instruction (CAI). Write a program that will help an eleme
    9·1 answer
  • _____ are the most fundamental components of designing a training program that determine the amount of stress placed on the body
    6·1 answer
  • How does the author of let bindi have the limelight persuade readers to consider the importance of wildlife conservation
    9·2 answers
  • What are 2 ways to access the vendor credit screen in quickbooks online?
    13·1 answer
  • I need help in raft survival ocean nomad I was traveling and now I can't enter the island or go back home (raft). Please help me
    15·1 answer
  • My pc suddenly freezes and i can't open any apps or task manager. Apps do not open at all and if i restart from the start it get
    9·1 answer
  • How do you change the colors of files?
    11·1 answer
  • Which of the following should be clicked to open Backstage View?
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!