Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The data consists of energy consumption for various types of fuel for each state and Washington DC (DC) expressed in trillions of BTUs. We will

The data consists of energy consumption for various types of fuel for each state and Washington DC (DC) expressed in trillions of BTUs. We will read in the data per state and compute a total energy consumption for five categories as follows:

1. coal

2. natural gas

3. petroleum: Fuel Oil + Jet Fuel + LPG + Motor Gasoline + Residual Fuel Oil

4. nuclear

5. renewables: Hydroelectric Power + Wood and Waste + Fuel Ethanol + Geothermal + Solar + Wind

Part 1: Data Analysis - a Command-Line State Energy Consumption Query: Create a command line menu driven application to display a states total energy consumption for coal, natural gas, petroleum and renewables. The first part of the assignment will be to create a program named A03.cpp that will read in a data file called Data2015.csv using C++ file stream operators. The data is stored in a commaseparated values (csv) file. To correctly read the data into an array, the commas, spaces, newlines (whitespace) and header row (first row) must be ignored. File I/O can be performed using ifstream and iostream located in the #include standard library.

Data Processing

The data will be read into the program using a function called: ReadData(. . . ) with the following formal parameters: an ifstream &, a data structure (e.g. an array-of-structs, etc.) and the number of states (51 in our dataset that includes Washington D.C.). The ReadData(. . . ) function will compute the state energy consumption totals for each group (coal, natural gas, petroleum, nuclear, renewables) as described above and store the result in an array or other data structure used in the application.

Database Interface

After the data is loaded and processed, a command-driven interface will allow a user to enter a state name. The interface will query the preprocessed data and display the states energy consumption as a percentage of that states total energy consumption. For example, California consumes 31 trillion BTUs of coal annually with a total energy consumption of 6506 trillion BTUs. The states total was computed by adding up the five energy groups. The percentage of a given energy is then computed by: 31./6506. 100 = 0.35%. Note that the number of digits printed must be controlled with the stream formatting options.

An example of the output and user interaction using the database: Enter a statename or q to exit:

California Coal: 0.48%

Natural Gas: 36.61%

Petroleum: 46.95%

Nuclear: 2.97%

Renewables: 12.99%

Enter a statename or q to exit:

New York Coal: 1.16%

Natural Gas: 39.43%

Petroleum: 34.79%

Nuclear: 13.16%

Renewables: 11.45%

Enter a statename or q to exit:

Wyoming Coal: 59.90%

Natural Gas: 18.07%

Petroleum: 16.13%

Nuclear: 0.00%

Renewables: 5.90%

Enter a statename or q to exit:

Colorado Coal: 24.52%

Natural Gas: 35.52%

Petroleum: 31.22%

Nuclear: 0.00%

Renewables: 8.75%

Enter a statename or q to exit:

Montana Coal: 35.98%

Natural Gas: 15.05%

Petroleum: 24.81%

Nuclear: 0.00%

Renewables: 24.16%

Enter a statename or q to exit: q Goodbye

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

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students also viewed these Databases questions

Question

Which personal relationships influenced you the most?

Answered: 1 week ago

Question

What were your most important educational experiences?

Answered: 1 week ago