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

Ok I have been working on this C++ program. I get it to compile and run but it i

ID: 674459 • Letter: O

Question

Ok I have been working on this C++ program. I get it to compile and run but it is not writing to new file. I need explanation on why it isn't writing to new file.

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main()

{
   ifstream MasterFile;
   ifstream TransactionFile;
   ofstream New_MasterFile;
   int mClientNumber;
   double mtotalClientCost;
   int tClientNumber;
   double titemClientCost;
   string mClientfName;
   string mClientlName;
  
   cout << "Master File Updating Starting" << endl;
  
   MasterFile.open("Master.rtf");
   TransactionFile.open("Transaction.rtf");
   New_MasterFile.open("newMaster.rtf");
  
   MasterFile >> mClientNumber;
   MasterFile >> mClientfName;
   MasterFile >> mtotalClientCost;
   MasterFile >> mClientlName;
   TransactionFile >> tClientNumber;
   TransactionFile >> titemClientCost;
  
   while(TransactionFile.eof())
  
   {
       while((MasterFile.eof()) && (mClientNumber < tClientNumber))
       {
      
       New_MasterFile << mClientNumber;
       New_MasterFile << mClientfName;
       New_MasterFile << mClientlName;
       New_MasterFile << mtotalClientCost;
      
       MasterFile >> mClientNumber;
       MasterFile >> mClientfName;
       MasterFile >> mClientlName;
       MasterFile >> mtotalClientCost;
      
      
       }
           if(MasterFile.eof())
       {
          
           cout << "ERROR Client ID:" << tClientNumber << "not in Master File.";
      
           }
          
           else if (mClientNumber==tClientNumber)
          
           {
               mtotalClientCost = mtotalClientCost + titemClientCost;
              
               New_MasterFile << mClientNumber;
               New_MasterFile << mClientfName;
               New_MasterFile << mClientlName;
               New_MasterFile << mtotalClientCost;
              
               MasterFile >> mClientNumber;
               MasterFile >> mClientfName;
               MasterFile >> mClientlName;
               MasterFile >> mtotalClientCost;
              
           }
          
           else if (mClientNumber > tClientNumber)
          
           {
               cout << "Error Client ID:" << tClientNumber << "Not in Master File.";
              
           }
          
           TransactionFile >> tClientNumber;
           TransactionFile >> titemClientCost;
          
           }
          
           while (MasterFile.eof())
          
           {
               New_MasterFile << mClientNumber;
               New_MasterFile << mClientfName;
               New_MasterFile << mClientlName;
               New_MasterFile << mtotalClientCost;
              
               MasterFile >> mClientNumber;
               MasterFile >> mClientfName;
               MasterFile >> mClientlName;
               MasterFile >> mtotalClientCost;
           }
          
       cout << "Master File Updating Complete" << endl;
      
       MasterFile.close();
       TransactionFile.close();
       New_MasterFile.close();
      
       system("Pause");
       return 0;
      
  
}

Transaction File

1 568.34
5 345.10
6 1012.43
17 2045.12
100 1231.00
101 167.39
125 5239.67

Master File

5 Mike Smith 2098.72
6 Sue Nathan 1234.32
100 Bobby Jones 519.69
125 Sally Mayer 345.74
200 Danny Glover 5623.18

Explanation / Answer

To begin with, in spite of the fact that our projects will be composed inside .cpp records, the .cpp documents themselves will be added to a task. The task stores the names of all the code records we need to gather, furthermore spares different IDE settings. Each time we revive the undertaking, it will restore the condition of the IDE to where we cleared out off. When we decide to order our system, the task tells the compiler and linker which records to accumulate and interface. It is significant that venture documents for one IDE won't work in another IDE. You should make another undertaking for every project you compose (or overwrite an old one).

Second, there are various types of undertakings. When you make another venture, you will need to pick an undertaking sort. The greater part of the tasks that we will make in this instructional exercise will be reassure ventures. A console venture implies that we are going to make programs that can be keep running from the dos or linux charge line. Naturally, support applications have no graphical client interface (GUI) and are arranged into stand-alone executable documents. This is ideal for learning C++, on the grounds that it keeps the intricacy to a base.

Third, when you make another undertaking for your system, numerous IDEs will consequently add your task to a "workspace" or an "answer". A workspace or arrangement is a compartment that can hold one or more related ventures. Despite the fact that you can add various tasks to a solitary arrangement, we suggest making another workspace or answer for every system. It's more straightforward and there's less risk of something turning out badly.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote