Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to make these three working programsinto one. they are designed to comple

ID: 3622304 • Letter: I

Question

 I need to make these three working programsinto one.  they are designed to complement one full process.  (i did this )  but I havent add any program to another before .  can you show me how since I need to make the program work?  
[code]
#include <stdlib.h>
#include <time.h>
#include<iostream>
#include<fstream>
#include<string>
#include<stdio.h>
using std :: cout;
using namespace std;
int main(){

int select;
cout<< "Press 1 for Encoding or Press 2 for Decoding" <<endl;
cin >> select;
switch (select)
{
case 1:;
goto Program;
case 2:;
goto Second;
} return 0;
}[code]

[code]
 #include <stdlib.h>
#include <time.h>
#include <iostream>
#include <fstream>
#include <stdio.h>

using namespace std;
program:
void nulls(){
int NULLS;
char random;
char filename [80];
char buffer ;

cout<< "File name:";
cin>> filename;

cout<<"Enter NULLS for Cipher";
cin >> NULLS;
srand((unsigned) time(NULL));

ifstream fin(filename);
cout << "Encryption Xomplete ";
char ch;
while (fin.get(ch)){
cout<< ch;
for (int i =0; i<NULLS; i++){

random = (65+rand()%25);
cout<<random;
} ch++;


}fin.close ();
return 0;
}
[/code]
[code]
 #include<iostream>
#include<fstream>
#include<string>
#include<stdio.h>

using namespace std;

int main()
{
program :
char choice;
char letter;
int x = 1;
int y = 1;
int z;
string filename;
cout << "Please make sure the document is in the same file as the program, thank you!" << endl << "Please input document name: " ;
cin >> filename; //getline(cin, filename);
cout << endl;
cout << "'Every nth character is good', what number is n?: ";
cin >> z;
cout << endl;
z = z - 1;
ifstream infile(filename.c_str());
if(infile.is_open())
{
while(!infile.eof()) the file.
{
infile.get(letter);
if (x == y)
{
x++;
}
else
{
if((x - y) == z)
{
cout << letter;
y=x;
}
else
{
x++;
}
}
}
cout << endl << "Decryption complete...if unreadable, please check to see if your input key was correct then try again." << endl;
infile.close();
cout << "Do you wish to try again? Please press y then enter if yes (case senstive).";
cin >> choice;
if(choice == 'y')
{
goto program ;
}
}
else
{
cout << "Unable to open file, please make sure the filename is correct and that you typed in the extension" << endl;
cout << "IE:" << " filename.txt" << endl;
cout << "You input: " << filename << endl;
cout << "Do you wish to try again? Please press y then enter if yes (case senstive)." ;
cin >> choice;
if(choice == 'y')
{
goto program ;
}
}
getchar();
}
[/code]

Explanation / Answer

please rate - thanks

I don't understand your code to test it

but it's 1 program

#include <stdlib.h>
#include <time.h>
#include<iostream>
#include<fstream>  
#include<string>  
#include<stdio.h>  
using std :: cout;
using namespace std;
void program1();
void program2();
int main(){

int select;
cout<< "Press 1 for Encoding or Press 2 for Decoding" <<endl;
cin >> select;
switch (select)
{
case 1:;
      program1();
case 2:;
      program2();
}
system("pause");
return 0;
}
void program1()
{
        int NULLS;
        char random;
char filename [80];
char buffer ;

cout<< "File name:";
cin>> filename;

cout<<"Enter NULLS for Cipher";
cin >> NULLS;
srand((unsigned) time(NULL));

ifstream fin(filename);
cout << "Encryption Xomplete ";
char ch;
while (fin.get(ch)){
cout<< ch;
for (int i =0; i<NULLS; i++){

random = (65+rand()%25);
     cout<<random;
} ch++;


}fin.close ();
}
void program2()
{    char choice;
    char letter;
    int x = 1;   
    int y = 1;   
    int z;             
    string filename;   
    cout << "Please make sure the document is in the same file as the program, thank you!" << endl << "Please input document name: " ;
    cin >> filename; //getline(cin, filename);
    cout << endl;
    cout << "'Every nth character is good', what number is n?: ";
    cin >> z;
    cout << endl;
    z = z - 1;
    ifstream infile(filename.c_str());
    while(!infile.is_open())
    {
        cout << "Unable to open file, please make sure the filename is correct and that you typed in the extension" << endl;
        cout << "IE:" << "     filename.txt" << endl;
        cout << "You input: " << filename << endl;
        cout << "Do you wish to try again? Please press y then enter if yes (case senstive)." ;
        cin >> choice;
        if(choice != 'y')
        {
               return ;
        }
    }
      while(!infile.eof())  
        {      
                        infile.get(letter);
                        if (x == y)         
                        {
                                x++;           
                        }
                        else
                        {
                                if((x - y) == z)                       
                                {
                                        cout << letter;                
                                        y=x;                                 
                                }
                                else                                           
                                {                                                      
                                        x++;
                                }
                        }
        }
        cout << endl << "Decryption complete...if unreadable, please check to see if your input key was correct then try again." << endl;
        infile.close();
        }