Question

Write a C++ program. Please use Codeblocks, show output. And provide all three files as asked...

Write a C++ program. Please use Codeblocks, show output. And provide all three files as asked and instructions on the combination and anything else.
The menu must ask how many names they wish to enter. Max is up to 20. And the end of each prompt please ask “Do you want to continue or Quit” so after each execution of the program it doesn’t automatically quit but gives the option to either repeat or quit through selection.

media%2F53c%2F53c4827b-a85c-45c7-a727-83
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>
#include<fstream>
using namespace std;
int main()
{
int size;
char first[20][20],last[20][20];
while(1)
{
cout<<"How many names you wish to enter:";
cin>>size;
if( size<=0 || size>20 )
{
cout<<"error size should be 1 to 20"<<endl<<"re-enter"<<endl;
continue;
}
int i=0;
cout<<"First names:"<<endl;
while(i<size)
cin>>first[i++];
i=0;
cout<<endl<<"Last names:"<<endl;
while(i<size)
cin>>last[i++];
ofstream out1,out2,out3;
out1.open("First.dat");
out2.open("Last.dat");
i=0;
while(i<size)
{
out1<<first[i]<<endl;
out2<<last[i]<<endl;
i++;
}
out1.close();
out2.close();
ifstream in1,in2,in3;
in1.open("First.dat");
in2.open("Last.dat");
out3.open("Full.dat");
i=0;
char arr[20];
while(i<size)
{
in1>>arr;
out3<<arr<<" ";
in2>>arr;
out3<<arr<<endl;
i++;
}
in1.close();
in2.close();
out3.close();
in3.open("Full.dat");
i=0;
cout<<endl<<"The combined names are:"<<endl;
while(i<size)
{
in3>>arr;
cout<<arr<<" ";
in3>>arr;
cout<<arr<<endl;
i++;
}
in3.close();
cout<<endl<<"Enter 1 to continue:";
int num;
cin>>num;
if(num!=1)
return 0;
}
return 0;
}

#include<iostream> #include<f3tream> using namespace std; int main () 2 int size char first[201 [201,last [20] [20] while (1) 7 10 cout<<How many names you wish to enter:; cin>>size if( size<#0 11 size>20 ) 13 cout<< error continue size should be 1 to 20くくend!<< re-enterくくendl ; 15 17 18 19 int i=0; cout<<First names: <<endl; while (i<size) cin>>first[i++] 21 i-0: coutくくendl<< Last while (i<size) names: <<endl; cin>>last[i++ ofstream outi, out2,out3 outi.open (First.dat) out2.open (Last.dat) i=0; whi le ( 1<si ze ) 2 6 27

sample input-output

Add a comment
Know the answer?
Add Answer to:
Write a C++ program. Please use Codeblocks, show output. And provide all three files as asked...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please i need the .H, .cpp and main.cpp files. Please use vector. its for my midterm so correct code that can run only....

    Please i need the .H, .cpp and main.cpp files. Please use vector. its for my midterm so correct code that can run only. Thank you. Pointers and Dynamic Memory – Chapter 11 1. Write code using pointers and the Accounts class from week 1 assignment as follows – create a program in which you a. Create 10 accounts using an array with id’s 0 to 9 and refer to each account using pointer notation b. Add an initial balance of...

  • C++ programming For this assignment, write a program that will act as a geometry calculator. The...

    C++ programming For this assignment, write a program that will act as a geometry calculator. The program will be menu-driven and should continue to execute as long as the user wants to continue. Basic Program Logic The program should start by displaying a menu similar to the following: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice(1-3): and get the user's choice as an integer. After the choice...

  • Write a complete C++ program that will: Declare a vector of integers Use a pointer to...

    Write a complete C++ program that will: Declare a vector of integers Use a pointer to dynamically allocate an array of 10 elements Ask the user how many values they would like to have in the data structures Read in the user’s response and make sure that it is greater than 20 (error loop) Generate the number of integers that the user asked for and store them into both data structures. The integer values should be unique unordered values (no...

  • In C++ please! Please include .cpp and .hpp files! Thank you! Recursive Functions Goals Create and...

    In C++ please! Please include .cpp and .hpp files! Thank you! Recursive Functions Goals Create and use recursive functions In this lab, we will write a program that uses three recursive functions. Requirements: Important: You must use the array for this lab, no vectors allowed. First Recursive Function Write a function that recursively prints a string in reverse. The function has ONLY one parameter of type string. It prints the reversed character to the screen followed by a newline character....

  • I need a C++ program like this please! and please follow all instructions! Thanks so much!...

    I need a C++ program like this please! and please follow all instructions! Thanks so much! A menu-driven program with 3 choices: Names Rearranger, Number Validator, or Exit Menu Option 1: Name Rearranger: 1. Input ONE STRING from the user containing first name, middle name, and last name. ie, "John Allen Smith". USE THE GETLINE function. (Not cin) 2. Loop through the string and validate for a-z or A-Z or . If the name has any other characters, then ask...

  • C# Write a program that takes a list of information and grades of the students of...

    C# Write a program that takes a list of information and grades of the students of a class and perform some processing. Take the following steps to write the program. The program must give the user two options such as a menu. At the beginning of the program must ask the following from the user: Which task you want to do (choose an option between 1-2), 1- Entering new information 2- Searching a student If the user types something rather...

  • Write MIPS code, please. Following: Write a program to be used by the Wisconsin DNR to...

    Write MIPS code, please. Following: Write a program to be used by the Wisconsin DNR to track the number of Deer Hunting Licenses issued in a county and the state. It will display a menu with 5 choices numbered 1-5. They are (1) update the count, (2) display the number of licenses already issued to a county whose number is input, (3) display the county number and the number of licenses already issued to a range of counties whose starting...

  • Please solve using c++ plus There are two text files with the following information stored in...

    Please solve using c++ plus There are two text files with the following information stored in them: The instructor.txt file where each line stores the id, name and affiliated department of an instructor separated by a comma The department.txt file where each line stores the name, location and budget of the department separated by a comma You need to write a C++ program that reads these text files and provides user with the following menu: 1. Enter the instructor ID...

  • Please write c++ (windows) in simple way and show all the steps with the required output

    please write c++ (windows) in simple way and show all the steps with the required output Write a C++ program that simulates the operation of a simple online banking system The program starts by displaying its main menu as shown in Figure1 splay Account nformatson verity Your credit Card elect vour choice Figure 1 Main menu of the program The menu is composed of the following choices 1. When choice 1 is selected (Display Account information), the program should display...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT