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
How do I learn coding? Python
pickupchik [31]

first learn the basics about the computer than just slowing move into it you feel?

5 0
3 years ago
Read 2 more answers
High level language - An object oriented programming language​
Pani-rosa [81]
Answer: Python
•If you want an example of high level programming at the same time its object oriented one is example is “Python”

• If your question is what is high level programming and what is Object Oriented programming I’ll explain. ⬇️

High level programming is a computer language which is closer to human languages.

Object oriented programming- view the picture.


3 0
3 years ago
Consider a Games Expo for Children. Six competitions are laid out for the expo. Tickets are sold according to the age and gender
AysviL [449]

Answer:

The program to this question can be defined as follows:

Program:

import java.util.*;  //import package for user-input

public class GamesExpo //defining GamesExpo class

{    

public static void main(String ag[]) //defining main method

{              

int age,gender; //defining integer variable

System.out.println("Welcome to Games Expo: ");   //print message

System.out.println("Enter age to get your type of games: ");//print message  

Scanner ob2=new Scanner(System.in); //creating scanner class object

age= ob2.nextInt(); // input value in age variable

System.out.println("Enter Gender, 1 for boy, 0 for girl"); //print message  

gender= ob2.nextInt(); // input value in gender variable

//defining conditional statement and print value according to user input  

if(gender==0) //if gender assign a value that is 0.

{

if(age>7 && age<10) //check age is in between 7 to 10  

{

System.out.println("Drawing");  //print message

}

else if(age>10 && age<15) //check age is in between 10 to 15

{

System.out.println("Essay Writing");  //print message

}

else if(age>20) //check age is greater 20

{

System.out.println("Poetry");  //print message

}

else // else block

{

System.out.println("Rhyming"); //print message

}

}

else if(gender==1) ///check gender value is equal to 1

{

if(age>7 && age<10) //check age is in between 7 to 10

{

System.out.println("Storytelling");  //print message

}

else if(age>11 && age<15) //check age is in between 11 to 15

{

System.out.println("Quiz");  //print message

}

else if(age>20) //check age is greater 20

{

System.out.println("Poetry");  //print message

}

else //else block

{

System.out.println("Rhyming");//print message

}

}

else //else block

{

System.out.println("Wrong choices");    //print message

}

}  

}

Output:

Welcome to Games Expo:  

Enter age to get your type of games:  

12

Enter Gender, 1 for boy, 0 for girl

1

Quiz

Explanation:

In the above program, first import the package for user input then defines the two integer variable "age and gender", in which we take input from the user end, by creating scanner class object, in the next line, the conditional statement is defined, that first checks the input value and print its value according to the condition.  In this program, there are multiple condition statement is used so, these conditions can be explained by the given output:

  • In the code execution time, first, it will input age, according to the age value, it will find the game in the given condition, for example, user input age value, i.e. equal to "12".
  • In this age value, it will select two games, for boys, it will select "Quiz", and for the girl, it will select "Essay Writing".
  • Then it will input the value of the gender, 1 for boy and 0 for a girl. if user input 1 so it will print "quiz", otherwise it will print "Essay Writing".
3 0
3 years ago
A Network Attached Storage device is good for _____.
igomit [66]

Answer:

sharing data across multiple workstations on the same network

Explanation:

A Network Attached Storage device is good for sharing data across multiple workstations on the same network.

3 0
3 years ago
Read 2 more answers
The two types of objects responsible for collecting data are
andrezito [222]
Hey there,
The answer is <span>tables and forms

Hope this helps :))

~Top
</span>
7 0
3 years ago
Other questions:
  • What special member function of a class is called whenever an instance of a class is created and initialized?
    15·1 answer
  • Compose a program to examine the string "Hello, world!\n", and calculate the total decimal numeric value of all the characters i
    7·1 answer
  • In terms of object-oriented programming, after a class is defined,
    11·1 answer
  • What is the best way to locate where my C program gets into an infinite loop
    5·1 answer
  • Whats the most popular social networking in the philippines?
    10·1 answer
  • A host is on the 192.168.146.0 network that has a subnet mask of 255.255.255.0. The binary value of the host portion is 11010101
    8·1 answer
  • What code would you use to create the login button?
    11·1 answer
  • B) The company's chief financial officer recognizes the need for an upgrade to the smart watches, but does not understand why th
    8·1 answer
  • Which statement about analog and digital images is true?.
    15·1 answer
  • GIF is example of raster image<br><br><br> RIGHT OR WRONG?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!