Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help on this C++ program no short cuts just as the direction askes if possible thank This is an exercise to create a data

Need help on this C++ program no short cuts just as the direction askes if possible thank

This is an exercise to create a data file from the contents of variables.

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.

Description

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 day1 = "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 day1Exp = 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 ofstream variable. Use a meaningful name for the variable. For example, outFile.

Use the ofstream variable to open the file using the named string constant defined above.

Use the insertion operator << to insert the variable for the first day and then the variable for the expense of the first day in that order.

Do the same thing for the other six days and expenses.

Close The File

Use the ofstream variable to close the file.

Report

Inform the user that the file expenses.txt has been created.

Use cout to inform the user that the file expenses.txt has been created. You must use the named constant for the file name in the cout statement. That is, the following statement will not be accepted.

cout << "File expenses.txt has been created." << ends;

Run and Check The File

Now the contents of the variables have been saved to the file, expenses.txt. The file is expected to be in the same folder where the executable of the program is.

The saved file should have the following formatted contents when you open it with a text editor.

Sunday 45.25

Monday 49.38

Tuesday 12.75

Wednesday 123.50

Thursday 8.25

Friday 19.95

Saturday 145.70

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions

Question

Q.1. Taxonomic classification of peafowl, Tiger and cow ?

Answered: 1 week ago

Question

Q .1. Different ways of testing the present adulterants ?

Answered: 1 week ago

Question

Q.1. Health issues caused by adulteration data ?

Answered: 1 week ago

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago