File.txt contains two lines: This And this is line2 What is the output of the following code snippet? int main() { ifstream read_file; read_file.open ("File.txt"); string linel, line2; read_file >> linel; getline (read_file, line2); cout << linel << endl; cout <
Q: A MyPetStore sells many pets and their accessories. As new pets are added to the MyPetStore, their…
A: Step 1: Implementation of Pet class: class Pet { private String name; private LocalDate…
Q: Write a program that reads in the first and last name of a person and formats the full name as the…
A: The Answer is in below Steps:-
Q: namespace
A:
Q: #include #include #include using namespace std; struct Player { string firstName;…
A: #include <iostream>#include <vector>#include <algorithm> using namespace std;…
Q: 7. Select the value of target so that the following code outputs: 8 std::string str = "appalachian…
A: Your answer is given below as you required with explanation.
Q: main.cc file
A: Cup Class Definition (cup.h):Define a class named Cup.Declare private member variables: drink_type_…
Q: 3) Implement the if __name__ == "__main__" : block at the bottom of this file to do the following:…
A: We have to write the code for implementing if __name__ == "__main__" : block at the bottom , also we…
Q: Write a function that receives a string consisting of several lines of text (paragraph) and returns…
A: Since there is no language given in the question i am using c++.Algorithm: Count Letters in a…
Q: main.cc file #include #include #include #include "cup.h" int main() {…
A: C++ which refers to the one it is a general-purpose programming language. It is a cross-platform…
Q: and list processing You will write a program to read grade data from a text file, displays the…
A: def read_grades(): # prompts for a file, read grades from file into a list and return the list…
Q: clude #include #include "cup.h" int main() { std::string drink_name; double amount = 0.0;…
A: The code you provided seems to be incomplete, as there are placeholders for you to write your own…
Q: I have a problem with this code can please fix it and explain it for me: //header files…
A: I have given an answer in step 2.
Q: #include <iostream> using namespace std; void additionProblem(int topNumber, int bottomNumber)…
A: Algorithm : 1. Start 2. Initialize the correct count variable to 0. 3. Initialize the count variable…
Q: There is a code below this template. The template must be implemented into the code but I am unable…
A: Note: The below code is based on template. MODIFIED PROGRAM: // -- brief statement as to the…
Q: COMPUTER SCIENCE 130 JAVA PROGRAM Chapter 4. Homework Assignment (read instructions carefully)…
A: 1. Initialize a Scanner for user input and a String variable 'fileName' to store the input file…
Q: P| Understanding if Statements In this lab, you complete a prewritten C++ program for a carpenter…
A: Given: // HouseSign.cpp - This program calculates prices for custom made signs. #include…
Q: main.cc file #include #include #include #include "cup.h" int main() { std::string…
A: C++ is a popular programming language. C++ is a cross-platform language that can be used to create…
Q: I need a function that takes a string and returns initials such as Bob Burnett becoming B.B. string…
A: A C++ program takes the phrase as input and displays its acronym. the acronym is an abbreviated word…
Q: In this lab, you use what you have learned about searching an array to find an exact match to…
A: #include <iostream>#include <string>using namespace std; int main() { string…
Q: #include #include #include #include #include #include "CommonName.h" #include "Name.h"…
A: Introduction C++ Class: The fundamental unit of Object-Oriented programming in C++ is a class. It's…
Q: #include #include using namespace std; enum MenuSelection { ADD = 43,…
A: PROGRAM: #include <stdio.h> #include <stdbool.h> //Defining enum enum MenuSelection {…
Q: #include #include using namespace std; int main() { char s1[50],s2[50]; int…
A: Objective: A program is given to read two strings from the user and join them. The program should be…
Q: thedW.d What will the following code display? void showDub (int); 5. int main () int x = 2; cout « x…
A: Step 1:- Given:- void showDub(int);int main(){ int x=2; cout<<x<<endl;…
Q: Please provide proper comments. Define the following code. #include 2 #include 3 4 #define…
A: This is the C language code which is playing some songs and calculating their playing time in…
Q: #include using namespace std; int binarySearch(int[], int, int, int); int main () { int…
A: #include<iostream>using namespace std;int main(){ int arr[10] = {16, 19, 20, 23, 45, 56,…
Q: #include using namespace std; int main() { string name,address,c_qual,c_spec,c_status; int…
A: As I go through the code I found you didn't check that entered value is an integer or not. so you…
Q: main.cc file #include #include #include "time_converter.h" int main() { int…
A: Introduction A header file in C++ is a file that contains declarations of functions, variables, and…
Q: C LANGUAGE PLS HELP #include // Do not edit these directives or add another. #include…
A: It is defined as a general-purpose, procedural, imperative computer programming language developed…
Q: Flowchart, create. #include #include using namespace std; double computeRate(int); double…
A: Here our ask is to draw a flow chart to the given program. First, let's understand the program a…
Q: Write a program named Lab9b_Act1.py that opens a file named Celsius.txt that contains a list of…
A: Algorithm : Step 1 : open the Celsius.txt file in read mode. Step 2 : open the Fahrenheit.txt file…
Q: The beginning of the code is given below. #include #include typedef struct{ char…
A: Actually, program is a executable software that runs on a computer.
Q: writes a line of text str from the file myfile reads a line of text to str from the file myfile…
A: Dear Student, getline() function is used in c++ to read a line from a file and store that line in a…
Q: his program converts characters to lowercase and uppercase
A: The problem statement is to convert an uppercase string to lowercase and store it in result1. And…
Q: // MichiganCities.cpp - This program prints a message for invalid cities in Michigan. // Input:…
A: You need to check with each and every element in the array of strings and if it equals the input…
Q: Mumber of Novels Authored Author Jane Austen Charles Dickens Ernest Hemingway Jack Kerouac Number of…
A: We need to read from the text file so streams are used. For formatting the strings iomanip functions…
Q: Modify to do the following: Add data integrity handing using cin.ignore, etc. for the initial…
A: There are very small modification you can add into this. I run this code on my system and its…
Q: #include using namespace std; int binarySearch(int[], int, int, int); int main () { int arr[10] =…
A: Include the header files Declare the Global variable count and initialize it to 0 Declare the binary…
Q: Create two more functions (options #3 and #4 in your menu) by taking the to_celsius() and…
A: C++ program for the above two problems :
Q: When using the ReadLine function on a StreamReader object, it is important to determine whether or…
A: It is essential to check the value of the EndOfStream property on a StreamReader object before…
Step by step
Solved in 3 steps
- convert it into file handling. #include<iostream>#include<conio.h>#include<string>#include<fstream>using namespace std;class votes{private:int no_of_people = 0;string arr[15] = { "Arif ur Rehman", "Waqar Chohan", "Sumaira Kausar", "Momina Moetesum","Muhammad Muzammal" };int no[15] = { 77,56,55,44,36 };public:void work(){string name;char selection;do{cout << "\n Enter The name of Candidate you Like: ";getline(cin, name);char press;for (int i = 0; i < 10; i++){if (name == arr[0]){no_of_people = no[0];}else if (name == arr[1]){no_of_people = no[1];}else if (name == arr[2]){no_of_people = no[2];}else if (name == arr[3]){no_of_people = no[3];}else if (name == arr[4]){no_of_people = no[4];}else if (name == arr[5]){no_of_people = no[5];}if (name == arr[i]){cout << "\n The Candidate is in database. Already " << no_of_people << " people have voted for him.";cout << " Do you want to vote for him as well(y/n): ";cin >> press;if…>> classicVinyls.cpp For the following program, you will use the text file called “vinyls.txt” attached to this assignment. The file stores information about a collection of classic vinyls. The records in the file are like the ones on the following sample: Led_Zeppelin Led_Zeppelin 1969 1000.00 The_Prettiest_Star David_Bowie 1973 2000.00 Speedway Elvis_Presley 1968 5000.00 Spirit_in_the_Night Bruce_Springsteen 1973 5000.00 … Write a declaration for a structure named vinylRec that is to be used to store the records for the classic collection system. The fields in the record should include a title (string), an artist (string), the yearReleased (int), and an estimatedPrice(double). Create the following…for c++ need 3 files please all three files (character.h, castle.h, 81.cpp) you have been asked by a computer gaming company to create a role-playing game, commonly known as an rpg. the theme of this game will be of the user trying to get a treasure that is being guarded the user will choose a character from a list you create create a character class, in a file named character.h, which will: have the following variables: name race (chosen from a list that you create, like knight, wizard, elf, etc.) weapon (chosen from a list that you create) spells (true meaning has the power to cast spells on others) anything else you want to add the treasure will be hidden in one of the rooms in a castle create a castle class, in a file named castle.h, that will: have these variables: at least four rooms named room1, room2, etc. moat (which is a lagoon surrounding a castle) which boolean (not all castles have them) anything else you want to add create a default constructor for each class that…
- Given the following code: #include <iostream>using namespace std; // global variablesconst int ROWS = 10, COLS = 10; int main(){ char a[ROWS][COLS] = { { ' ', ' ', ' ', ' ', 'B', 'B', ' ', ' ', ' ', ' '} , { ' ', ' ', ' ', 'B', ' ', ' ', 'B', ' ', ' ', ' '}, { ' ', ' ', 'B', ' ', ' ', ' ', ' ', 'B', ' ', ' '}, { ' ', 'B', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' '}, { 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B'}, { 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B'}, { ' ', 'B', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' '}, { ' ', ' ', 'B', ' ', ' ', ' ', ' ', 'B', ' ', ' '}, { ' ', ' ', ' ', 'B', ' ', ' ', 'B', ' ', ' ', ' '}, { ' ', ' ', ' ', ' ', 'B', 'B', ' ', ' ', ' ', ' '} }; printArray( a, ROWS, COLS ); fillInside( a, ROWS, COLS, 'x' ); // Use the first letter of your first name printArray( a, ROWS, COLS ); fillInside( a, ROWS, COLS, ' ' ); fillOutside( a, ROWS, COLS, 'y' ); // Use the first letter of your last name printArray(…C++ this is my code so far need help with part 9 #include <iostream> #include <string> using namespace std; int GetNumOfNonWSCharacters(const string text); int GetNumOfWords(const string text); int FindText(string text, string sample_text); string ReplaceExclamation(string text); string ShortenSpace(string text); char PrintMenu(){ char option; cout << "\nMENU"<<endl; cout << "c - Number of non-whitespace characters"<<endl; cout << "w - Number of words"<<endl; cout << "f - Find text"<<endl; cout << "r - Replace all !'s"<<endl; cout << "s - Shorten spaces"<<endl; cout << "q - Quit"<<endl; cout<<endl; cout << "Choose an option:"<<endl; cin >> option; return option; } void ExecuteMenu(string sample_text,char option){ if(option == 'c'){ int nonWSCharacters = GetNumOfNonWSCharacters(sample_text); cout << "Number of non-whitespace characters:…In C++ PLEASE Use the text file from Chapter 12, forChap12.txt. SEE BELOW Write a program that opens a specified text file then displays a list of all the unique words found in the file. Addition to the text book specifications, print the total of unique words in the file. Text File = forChap12.txt No one is unaware of the name of that famous English shipowner, Cunard. In 1840 this shrewd industrialist founded a postal service between Liverpool and Halifax, featuring three wooden ships with 400-horsepower paddle wheels and a burden of 1,162 metric tons. Eight years later, the company's assets were increased by four 650-horsepower ships at 1,820 metric tons, and in two more years, by two other vessels of still greater power and tonnage. In 1853 the Cunard Co., whose mail-carrying charter had just been renewed, successively added to its assets the Arabia, the Persia, the China, the Scotia, the Java, and the Russia, all ships of top speed and, after the Great Eastern, the biggest ever…
- C++ PLEASE!! // FILE: simplestring.h// CLASS PROVIDED: string (a sequence of characters)//// CONSTRUCTOR for the string class:// string(const char str[ ] = "") -- default argument is the empty string.// Precondition: str is an ordinary null-terminated string.// Postcondition: The string contains the sequence of chars from str.//// CONSTANT MEMBER FUNCTIONS for the string class:// size_t length( ) const// Postcondition: The return value is the number of characters in the// string.//// char operator [ ](size_t position) const// Precondition: position < length( ).// Postcondition: The value returned is the character at the specified// position of the string. A string's positions start from 0 at the start// of the sequence and go up to length( )-1 at the right end.//// MODIFICATION MEMBER FUNCTIONS for the string class:// void operator +=(const string& addend)// Postcondition: addend has been catenated to the end of the string.//// void operator +=(const char addend[ ])//…Design a program that reads a file called sales.txt containing the following data: Jane, 215.5,445.5,910.0 John, 825.0,250.5,675.0 Bill,0.0,999.15 Each line has a employee's name and their weekly sales totals all separated by commas. Some employees have taken vacation some weeks so no numbers are captured for those weeks. Create a function that takes a list of floats and returns the average value for those numbers. After reading the information from the file, use a for loop to calculate the sales average using your new average function for each employee and display the following output to the screen. Jane, average sales: 523.67 John, average sales: 583.50 Bill, average sales: 499.56Need to use those main.cpp and IntList.h main.cpp #include "IntList.h" #include <iostream>using namespace std; int main(){cout << "Enter a test number(1-5): ";int test;cin >> test;cout << endl;//tests constructor, destructor, push_front, pop_front, displayif (test == 1) {cout << "\nlist1 constructor called";IntList list1;cout << "\npushfront 10";list1.push_front( 10 );cout << "\npushfront 20";list1.push_front( 20 );cout << "\npushfront 30";list1.push_front( 30 );cout << "\nlist1: ";list1.display();cout << "\npop";list1.pop_front();cout << "\nlist1: ";list1.display();cout << "\npop";list1.pop_front();cout << "\nlist1: ";list1.display();cout << "\npop";list1.pop_front();cout << "\nlist1: ";list1.display();cout << endl;}if (test == 1) {cout << "list1 destructor called" << endl;} //tests push_backif (test == 2) {cout << "\nlist2 constructor called";IntList list2;cout <<…
- #include <iostream>#include <sstream>#include <string>using namespace std; int main() { string userItem; ostringstream itemsOSS; cout << "Enter items (type Exit to quit):" << endl; cin >> userItem; while (userItem != "Exit") { cin >> userItem; } cout << itemsOSS.str() << endl; return 0;}Find a line with an error in the following code segment: 1: void displayFile(fstream file) {2: string line;3: while (file >> line) 4: cout << line << endl;5: } Group of answer choices 1 2 3 4// Swap.cpp - This program determines the minimum and maximum of three values input by // the user and performs necessary swaps. // Input: Three int values. // Output: The numbers in numerical order. #include <iostream> using namespace std; int main() { // Declare variables int first = 0; // First number int second = 0; // Second number int third = 0; // Third number int temp; // Used to swap numbers const string SENTINEL = "done"; // Named constant for sentinel value string repeat; bool notDone = true; //loop control // Get user input cout << "Enter first number: "; cin >> first; cout << "Enter second number: "; cin >> second; cout << "Enter third number: "; cin >> third; while(notDone == true){ // Test to see if the first number is greater than the second number // Test to see if the second number is greater than the third number // Test to…