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

Complete the program according to the following steps. Read the entire instructi

ID: 3858959 • Letter: C

Question

Complete the program according to the following steps. Read the entire instructions before writing code. In order to get 100%, the entire instructions must be followed. You should include a program description at the top of the program according to the template. You may simply use this sentence. "This program creates a data file in a predefined format to be used by other programs" Define and Initialize Variables. Define seven string variables and initialize them with the days of a week. Define one variable per line. Use meaningful names for the variables. For example, string day 1 = "Sunday": for the first day of the week. Define seven double variables and initialize them with the expenses of the week. Define one variable per line. Use meaningful names for the variables. For example, double day 1 Exp = 45.25: for the expense of the first day. Create a Data File Define a named string constant for the file name, "expenses.txt". Use a meaningful name for the variable. The name must be in uppercase Define an of stream variable. Use a meaningful name for the variable. For example, out File. Use the of stream variable to open the file using the named string constant defined above Use the insertion operator

Explanation / Answer

NOTE: Check the code and let me know if you face any issues. I will revert back within 24 hours.

Code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

// This program creates a predefined file format to be used by other programs

int main()
{
   string day1, day2, day3, day4, day5, day6, day7;
   double day1Exp, day2Exp, day3Exp, day4Exp, day5Exp, day6Exp, day7Exp;

   ofstream outFile ("expenses.txt", ofstream::out);

   day1 = "Sunday";
   day2 = "Monday";
   day3 = "Tuesday";
   day4 = "Wednesday";
   day5 = "Thursday";
   day6 = "Friday";
   day7 = "Saturday";

   day1Exp = 45.25;
   day2Exp = 20.10;
   day3Exp = 60.2;
   day4Exp = 102.24;
   day5Exp = 70.92;
   day6Exp = 64.45;
   day7Exp = 99.99;

   outFile << day1 << " " << day1Exp << " ";
   outFile << day2 << " " << day2Exp << " ";
   outFile << day3 << " " << day3Exp << " ";
   outFile << day4 << " " << day4Exp << " ";
   outFile << day5 << " " << day5Exp << " ";
   outFile << day6 << " " << day6Exp << " ";
   outFile << day7 << " " << day7Exp << " ";

   outFile.close();
   cout << "File expenses.txt has been created" << endl;

   return 0;
}


Execution and output screenshot:
https://pasteboard.co/GBSNoVM.png

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