public class ScenarioAnalysis { // Instance variables privateVehicle[] vehicles; // all vehicless being analyzed privatedoublegasPrice; // price of one gallon of gas in dollars privatedoubleelectricityPrice; // price of 1 kWh in cents of a dollar, c$/kWh publicScenarioAnalysis ( doublegasPrice, doubleelectricityPrice ) { this.gasPrice = gasPrice; this.electricityPrice = electricityPrice; } /* * Updates the price of gas * Call computeCO2EmissionsAndCost() whenever there is an update on gas prices */ publicvoidsetGasPrice ( doublegasPrice ) { this.gasPrice = gasPrice; computeCO2EmissionsAndCost(); } /* * Returns the gas price */ publicdoublegetGasPrice () { returngasPrice; } /* * Updates the price of electricity * Call computeCO2EmissionsAndCost() whenever there is an update on electricity prices */ publicvoidsetElectricityPrice ( doubleelectricityPrice ) { this.electricityPrice = electricityPrice; }   /* * Returns electricity price */ publicdoublegetElectricityPrice () { returnelectricityPrice; } /* * Computes and updates the CO2 emissions, fuel cost and total cost for each * vehicle in the vehicles array. */ publicvoidcomputeCO2EmissionsAndCost () {   // WRITE YOUR CODE HERE } /* * Returns vehicles array */ publicVehicle[] getVehicles () { returnvehicles; } /* * Prints all vehicles */ publicvoidprintVehicles () { for ( Vehiclev:vehicles ) { StdOut.println(v); } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

[java program]

public class ScenarioAnalysis {

// Instance variables
privateVehicle[] vehicles; // all vehicless being analyzed
privatedoublegasPrice; // price of one gallon of gas in dollars
privatedoubleelectricityPrice; // price of 1 kWh in cents of a dollar, c$/kWh

publicScenarioAnalysis ( doublegasPrice, doubleelectricityPrice ) {
this.gasPrice = gasPrice;
this.electricityPrice = electricityPrice;
}

/*
* Updates the price of gas
* Call computeCO2EmissionsAndCost() whenever there is an update on gas prices
*/
publicvoidsetGasPrice ( doublegasPrice ) {
this.gasPrice = gasPrice;
computeCO2EmissionsAndCost();
}

/*
* Returns the gas price
*/
publicdoublegetGasPrice () {
returngasPrice;
}

/*
* Updates the price of electricity
* Call computeCO2EmissionsAndCost() whenever there is an update on electricity prices
*/
publicvoidsetElectricityPrice ( doubleelectricityPrice ) {
this.electricityPrice = electricityPrice;
}
 
/*
* Returns electricity price
*/
publicdoublegetElectricityPrice () {
returnelectricityPrice;
}

/*
* Computes and updates the CO2 emissions, fuel cost and total cost for each
* vehicle in the vehicles array.
*/
publicvoidcomputeCO2EmissionsAndCost () {
 
// WRITE YOUR CODE HERE
}

/*
* Returns vehicles array
*/
publicVehicle[] getVehicles () {
returnvehicles;
}

/*
* Prints all vehicles
*/
publicvoidprintVehicles () {
for ( Vehiclev:vehicles ) {
StdOut.println(v);
}
}
**Considering Carbon**

Many people choose to buy an electric car, not because of cost but out of concern for the environment. This is a benefit that is difficult to fully capture, but certain things like greenhouse gas emissions can be measured.

Greenhouse gases (GHGs) trap heat in the Earth’s atmosphere and are believed to contribute to global climate change. Carbon dioxide (CO2) is the main GHG produced by human activity, and the two major human activities responsible for CO2 emission are electric power generation and combustion of fossil fuels for transportation. You can read a little more about CO2 emission on the EPA website.

According to the EPA, there are 8.887 kg of CO2 released with the combustion of each gallon of gasoline. This is the amount of CO2 coming out the tailpipe of a gas-powered vehicle.

This means that we can estimate the total CO2 emitted over the three-year lease of a vehicle. Assuming the vehicle consumes 1 gallon of gas for every 34 miles and that the lease allowance mileage is 12,000 miles per year, we can compute the number of gallons of gasoline needed to drive an estimated 36,000 miles and multiplying by 8.887 kg/gal as follows:

\[ 36,000 \text{ mi}/(34 \text{ mi/gal}) \times 8.887 \text{ kg/gal} = 1,058.82 \text{ gal} \times 8.887 \text{ kg/gal} = 9,409.76\text{ kg}.\]

To drive 36,000 miles, the vehicle uses 1,058.82 gallons of gasoline and produces 9,409.76 kg of CO2.

You can do this same calculation for any gas-powered car by plugging in the number of miles driven (M) and the fuel efficiency of the vehicle in miles per gallon (N).

\[ \text{Total kg of CO2 emitted} = \left(\frac{M \text{ miles}}{N \text{ miles/gallon}}\right) \times 8.887 \text{ kg CO2/gallon} \quad \text{(Equation 1)} \]

To figure out how much CO2 is emitted in generating the electricity to charge the battery of an electricity-powered car over a three-year lease, let’s begin by estimating the total energy for battery charging needed to drive 36,000 miles. Assuming that
Transcribed Image Text:**Considering Carbon** Many people choose to buy an electric car, not because of cost but out of concern for the environment. This is a benefit that is difficult to fully capture, but certain things like greenhouse gas emissions can be measured. Greenhouse gases (GHGs) trap heat in the Earth’s atmosphere and are believed to contribute to global climate change. Carbon dioxide (CO2) is the main GHG produced by human activity, and the two major human activities responsible for CO2 emission are electric power generation and combustion of fossil fuels for transportation. You can read a little more about CO2 emission on the EPA website. According to the EPA, there are 8.887 kg of CO2 released with the combustion of each gallon of gasoline. This is the amount of CO2 coming out the tailpipe of a gas-powered vehicle. This means that we can estimate the total CO2 emitted over the three-year lease of a vehicle. Assuming the vehicle consumes 1 gallon of gas for every 34 miles and that the lease allowance mileage is 12,000 miles per year, we can compute the number of gallons of gasoline needed to drive an estimated 36,000 miles and multiplying by 8.887 kg/gal as follows: \[ 36,000 \text{ mi}/(34 \text{ mi/gal}) \times 8.887 \text{ kg/gal} = 1,058.82 \text{ gal} \times 8.887 \text{ kg/gal} = 9,409.76\text{ kg}.\] To drive 36,000 miles, the vehicle uses 1,058.82 gallons of gasoline and produces 9,409.76 kg of CO2. You can do this same calculation for any gas-powered car by plugging in the number of miles driven (M) and the fuel efficiency of the vehicle in miles per gallon (N). \[ \text{Total kg of CO2 emitted} = \left(\frac{M \text{ miles}}{N \text{ miles/gallon}}\right) \times 8.887 \text{ kg CO2/gallon} \quad \text{(Equation 1)} \] To figure out how much CO2 is emitted in generating the electricity to charge the battery of an electricity-powered car over a three-year lease, let’s begin by estimating the total energy for battery charging needed to drive 36,000 miles. Assuming that
According to the EPA's Power Profiler website, 998.4 pounds of CO2 are emitted per MWh on average across the United States.

Converting units, there are about 0.45 kg per pound, resulting in the following total CO2 emission in kg to power the car:

\[ 9,075.6 \text{ kWh} \times \left[ \frac{998.4 \text{ lbs CO}_2}{\text{MWh}} \times \frac{1 \text{ MWh}}{1000 \text{ kWh}} \times 0.45 \text{ kg/lb} \right] = 4077.5 \text{ kg CO}_2 \]

Given all of this, we now have the capability to estimate the CO2 emission resulting from driving an electric vehicle. It boils down to plugging in the number of miles driven (M), battery storage capacity (E), and the driving range on a charge (R) into the following equation.

\[ \left( \frac{M \text{ miles}}{R \text{ miles/charge}} \right) \times \left( \frac{E \text{ KWh/charge}}{} \right) \times \left[ \frac{998.4 \text{ lbs CO}_2}{\text{ MWh}} \times \frac{1 \text{ MWh}}{1000 \text{ KWh}} \times \frac{0.45 \text{ kg}}{\text{ lb}} \right] = \text{ kg of CO}_2 \quad \text{(Equation 2)} \]

This equation looks complex, but we can deconstruct it by noticing that the quantity in brackets on the left is electricity consumption, and the quantity in brackets on the right is essentially just unit conversions to get us from kWh of electricity to kg of CO2.

Given Equation 2 and Equation 1 from the previous section, we can figure out the CO2 emissions from any gas-powered car and any electric car, and that’s what we will do now.
Transcribed Image Text:According to the EPA's Power Profiler website, 998.4 pounds of CO2 are emitted per MWh on average across the United States. Converting units, there are about 0.45 kg per pound, resulting in the following total CO2 emission in kg to power the car: \[ 9,075.6 \text{ kWh} \times \left[ \frac{998.4 \text{ lbs CO}_2}{\text{MWh}} \times \frac{1 \text{ MWh}}{1000 \text{ kWh}} \times 0.45 \text{ kg/lb} \right] = 4077.5 \text{ kg CO}_2 \] Given all of this, we now have the capability to estimate the CO2 emission resulting from driving an electric vehicle. It boils down to plugging in the number of miles driven (M), battery storage capacity (E), and the driving range on a charge (R) into the following equation. \[ \left( \frac{M \text{ miles}}{R \text{ miles/charge}} \right) \times \left( \frac{E \text{ KWh/charge}}{} \right) \times \left[ \frac{998.4 \text{ lbs CO}_2}{\text{ MWh}} \times \frac{1 \text{ MWh}}{1000 \text{ KWh}} \times \frac{0.45 \text{ kg}}{\text{ lb}} \right] = \text{ kg of CO}_2 \quad \text{(Equation 2)} \] This equation looks complex, but we can deconstruct it by noticing that the quantity in brackets on the left is electricity consumption, and the quantity in brackets on the right is essentially just unit conversions to get us from kWh of electricity to kg of CO2. Given Equation 2 and Equation 1 from the previous section, we can figure out the CO2 emissions from any gas-powered car and any electric car, and that’s what we will do now.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education