#include<iostream>
#include<string>
#include<fstream>
using namespace std;
char toUpper(char ch) { //convert a char to upper case
if (ch >= 'a' && ch <= 'z')
ch = ch - 32;
return ch;
}
char toLower(char ch) { //conert a char to lower case
if (ch >= 'A' && ch <= 'Z')
ch = ch + 32;
return ch;
}
int main() {
string inFile;
cout << "Enter input file name: ";
cin >> inFile; //read file name
ifstream in (inFile.c_str()); //open infile
ofstream o1 ("Output1"); //open out files
ofstream o2 ("Output2");
ofstream o3 ("Output3");
int charCount = 0;
int lineCount = 0;
int maxLineSize = 0;
int currLineSize = 0;
char ch;
while (in >> noskipws >> ch) { //loop for each charecters
o1 << toUpper(ch); //print lower to file 1
o2 << toLower(ch); //print upper to file 2
if (ch == '\n'){ //count line when new line feed is encounters
lineCount ++;
if (currLineSize > maxLineSize)
maxLineSize = currLineSize;
currLineSize = 0;
}
else { //for other char count chars
charCount ++;
currLineSize ++;
}
}
o1.close();
o2.close();
o3 << "Total number of char: " << charCount << endl;
o3 << "Total number of lines: " << lineCount << endl;
o3 << "Max verse size: " << maxLineSize << endl;
cout << "Total number of char: " << charCount << endl;
cout << "Total number of lines: " << lineCount << endl;
cout << "Max verse size: " << maxLineSize << endl;
o3.close();
}
C++ please Write a program that reads the following sentences from a file: I am Sam...
Write a C++ program that reads text from a file and encrypts the file by adding 6 to the ASCII value of each character. See section 5.11 in Starting out with C++ for information on reading and writing to text files. Your program should: 1. Read the provided plain.txt file one line at a time. Because this file has spaces, use getline (see section 3.8). 2. Change each character of the string by adding 6 to it. 3. Write the...
Please write this in C. Write this code in Visual Studio and upload your Source.cpp file for checking (1) Write a program to prompt the user for an output file name and 2 input file names. The program should check for errors in opening the files, and print the name of any file which has an error, and exit if an error occurs opening any of the 3 For example, (user input shown in caps in first line) Enter first...
Lab #10 C++ Write a C++ program that reads text from a file and encrypts the file by adding an encryption factor (EF) to the ASCII value of each character. The encryption factor is 1 for the first line and increases by 1 for each line up to 4 and then starts over at 1. So, for the 4 th line the EF is 4, for the 5th line it is 1, for the 10th line it is 2. In...
//I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which manipulates text from an input file using the string library. Your program will accept command line arguments for the input and output file names as well as a list of blacklisted words. There are two major features in this programming: 1. Given an input file with text and a list of words, find and replace every use of these blacklisted words with the string...
C Program In this assignment you'll write a program that encrypts the alphabetic letters in a file using the Vigenère cipher. Your program will take two command line parameters containing the names of the file storing the encryption key and the file to be encrypted. The program must generate output to the console (terminal) screen as specified below. Command Line Parameters Your program must compile and run from the command line. The program executable must be named “vigenere” (all lower...
I am writing a program in C++, which requires me to read an input text file using command line argument. However, I am using xcode on my Macbook to write C++ program, and use terminal instead of command. How do you use int main(int argc, char** argv[]) to read an input file. My professor requires us not to hard code the text file name like .open("example.txt"); Thank you!
Using C++ programming. Write a program that takes a string of input from the user and separates the string of words based on the premise that the string contains words whose first letter is uppercase. Then, display the phrase (or sentence) to a string in which the words are separated by spaces and only the first word of the phrase starts with an uppercase letter. For example, if the user enters "IAmTheTeacher", then the program would display: "I am the...
Hello, I am struggling with this C# WPF application for one of my classes. I am using visual studio to work on it. The description for the problem is as follows: Create an app that can open a text file. Each line of the file contains an arbitrary number of words separated by spaces. Display the count for how many words are in the line and the count how many non-space characters are in the line on the form /...
please use c++ please write down the input file information please add comments for some codes please do not use #include <bits/stdc++.h> we did not learn it yet thank you CSIT 575-Take Home Lab #11: Arrays To learn to code, compile and run a program processing characters. Assignment Plan and code a top-down modular program utilizing ARRAYS to solve the following problem, using at least 3 functions (called from the main() section or from another function) to solve the problem....