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); } }
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
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 milage 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.887kg/gal as follows:
36,000mi/(34 mi/gal) x 8.887 kg/gal = 1,058.82 gal x 8.887kg/gal = 9,409.76kg.
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).
Mmiles
kg CO2
Total kg of CO, emitted =
× 8.887
(Equation 1)
miles
N-
gallon
gallon
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 it takes 60kWh to fully charge the car and that
the car can drive for 238 miles per charge we estimate the total energy needed for battery charging needed to drive 36,000 miles is:
36,000 mi/(238 mi/charge) x 60 kWh/charge = 9,075.6 kWh.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ff3952b7e-2fc8-4aa9-b8fa-d9d249446b27%2Fbdc92708-f8fc-4bde-81f5-29bb9bdc66c2%2Fexcsqid_processed.png&w=3840&q=75)
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 milage 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.887kg/gal as follows:
36,000mi/(34 mi/gal) x 8.887 kg/gal = 1,058.82 gal x 8.887kg/gal = 9,409.76kg.
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).
Mmiles
kg CO2
Total kg of CO, emitted =
× 8.887
(Equation 1)
miles
N-
gallon
gallon
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 it takes 60kWh to fully charge the car and that
the car can drive for 238 miles per charge we estimate the total energy needed for battery charging needed to drive 36,000 miles is:
36,000 mi/(238 mi/charge) x 60 kWh/charge = 9,075.6 kWh.
![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 .45kg per pound, resulting in the following total CO2 emission in kg to power the car:
9,075.6 kWh * [ 998.4 Ibs CO2/ MWh * 1MWH/1000Kwh * 0.45kg/lb ] = 4077.5 kg/CO2
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.
998.4 lbs CO2
.45kg
E KWh
charge
Mmiles
1MWH
= kg of CO2 (Equation 2)
miłes
R
charge
MWh
1000KWH
lb
This equation looks hairy, 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 C02 emissions from any gas-powered car and any electric car, and
that's what we will do now.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ff3952b7e-2fc8-4aa9-b8fa-d9d249446b27%2Fbdc92708-f8fc-4bde-81f5-29bb9bdc66c2%2Fy6hlssk_processed.png&w=3840&q=75)
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 .45kg per pound, resulting in the following total CO2 emission in kg to power the car:
9,075.6 kWh * [ 998.4 Ibs CO2/ MWh * 1MWH/1000Kwh * 0.45kg/lb ] = 4077.5 kg/CO2
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.
998.4 lbs CO2
.45kg
E KWh
charge
Mmiles
1MWH
= kg of CO2 (Equation 2)
miłes
R
charge
MWh
1000KWH
lb
This equation looks hairy, 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 C02 emissions from any gas-powered car and any electric car, and
that's what we will do now.
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
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.Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education