write a program in c++ to read the name of country from one text file and name of its corresponding capital city from another text file . the program must display the country name and indicates its corresponding capital for atleast five countries in output
Added by Ronald P.
Step 1
Sure! Here’s a step-by-step guide to create a C++ program that reads country names from one text file and their corresponding capital cities from another text file, then displays them. Show more…
Show all steps
Your feedback will help us improve your experience
Akash M and 88 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Write a C++ program that reads a list of telephone numbers expressed in capital letters from a text file and converts the telephone numbers in capital letters, to the corresponding telephone numbers in digits. Each converted phone number should be displayed on the console in both formats, alphabetic and digital. At the same time, the program creates another file in which the telephone numbers appear in digital format, one number per line. Allow the user to specify the name of the input file, as well as the name of the output file. Apply the following convention: If a number consists of more than seven letters, only the first seven letters are processed. A space is displayed between the third and fourth digits. Letters A, B and C corresponds to digit 2; letters D, E and F to digit 3; letters G, H and I to digit 4; letters J, K and L to digit 5; letters M, N and O to digit 6; letters P, Q R and S to digit 7; letters T, U and V to digit 8; and letters W, X, Y and Z to digit 9. If any other character is encountered, a * is displayed. The input file contains the following data, with one number per line: CALL HOME GET LOAN Hi THERE BYE FOR NOW HELP ME PAS
Akash M.
Write a C++ program that prompts the user to enter a file name that contains the scores of students in a quiz. Each line in the input file contains a student name followed by the student's score (as shown in the sample file to the right). The program should then find out the students with the minimum score and the maximum score and display their names and scores. Marks.txt Ahmed 90 Badria 85 Noor 91 Khalid 70 Said 65 Suha 80
John B.
I can't get it to work. Can someone help me read from a file? This is for C++. Write a program that reads the contents of a flat-text file and counts the number of uppercase letters (A-Z) found in that file. Use the "10,000 Random Words" file from Chapter 8. There is no need to use an array in this program; you can read the file one line at a time and process the text as it goes by until the entire file has been read. #include <iostream> #include <fstream> using namespace std; int main() { // Read from file.txt, can use any file, simply change the name here ifstream in("Text.txt"); int count = 0; // Reading file // END OF FILE (eof) method while (!in.eof()) { // Text.txt string text; // Extracting each line from the file getline(in, text); // Looping through each character for (int i = 0; i < text.length(); ++i) { // Storing character in 'ch' char ch = text[i]; // Checking if 'ch' is uppercase if (isupper(ch)) { count++; } } } cout << "Found uppercase letters in the file: "; cout << count << endl; return 0; }
Shu N.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD