Question

In: Computer Science

Suppose a gas company bases its charges on consumption according to the following table: Gas Charges...

Suppose a gas company bases its charges on consumption according to the following table:

Gas Charges
Gas Used Rate
First 70 cubic meters $5.00 minimum cost
Next 100 cubic meters $0.05 per cubic meter
Next 230 cubic meters $0.025 per cubic meter
Above 400 cubic meters    $0.015 per cubic meter   


Write a program in C++ that asks the user to enter the number of cubic meters of gas used, calculates the charges, and displays the total charge.

Solutions

Expert Solution

// C++ program that asks the user to enter the number of cubic meters of gas used, calculates the charges, and displays the total charge.

#include <iostream>

using namespace std;

int main()
{
double gasUsed, charges;

// input the number of cubic meters of gas used
cout<<"Enter the number of cubic meters of gas used: ";
cin>>gasUsed;

charges = 5; // set charges to base charge of 5
gasUsed -= 70; // subtract first 70 cubic meters from gasUsed

// initial gasUsed > 70
if(gasUsed > 0){
// next 100 cubic meters is charged at $0.05 per cubic meter
if(gasUsed > 100) // gasUsed > 100
charges += 100*0.05; // add charges for next 100
else // add charges for the left gas
charges += (gasUsed)*0.05;
gasUsed -= 100; // subtract 100 from gas used
}

// initial gasUsed > 170
if(gasUsed > 0)
{
// next 230 cubic meters is charged at $0.025 per cubic meter
if(gasUsed > 230) // gasUsed > 230
charges += 230*0.025; // add charges for next 230
else // add charges fro left gas
charges += gasUsed*0.025;
gasUsed -= 230; // subtract 230 from gas used
}

// initial gasUsed > 400
if(gasUsed > 0)
{
// above 400 cubic meters is charged at $0.015 per cubic meter
charges += gasUsed*0.015; // add charges for left gas
}

// display the charges to 2 decimal places
cout<<fixed;
cout.precision(2);

cout<<"Total charge: $"<<charges<<endl;
return 0;
}

//end of program

Output:


Related Solutions

An electricity company charges electricity consumption according to the following scale. Up to 200 Units (0-200)...
An electricity company charges electricity consumption according to the following scale. Up to 200 Units (0-200) to 0.25 € per unit The next 1000 Units (201-1200) to 0.40 € per unit Over 1200 units to 0.50 € per unit. Write a program in python language that accepts the number of units consumed by the customer and displays the amount of money owed by the customer to the electricity company
For an in-class demonstration with NO gas, I prepared the NO gas according to the following...
For an in-class demonstration with NO gas, I prepared the NO gas according to the following balanced equation: 2 NaNO2(s) + 3 H2SO4(aq) + FeSO4(aq)  2 NO(g) + Fe2(SO4)3(aq) + 2 NaHSO4(aq) + 2 H2O(l) Determine the volume of gas expected to be produced at 25 oC and barometric pressure = 782. torr (when vapour pressure of water = 24 torr) when 2.64 mL 3.00 M H2SO4(aq) is reacted with excess NaNO2(s) and excess FeSO4(aq).
Suppose you buy 40.46 pounds of propane for your gas grill. b. According to the following...
Suppose you buy 40.46 pounds of propane for your gas grill. b. According to the following reaction for the combustion of propane, what is the mass (in grams) of water that will be produced by the combustion of the entire tank? C3H8(l) + 5 O2(g) → 3 CO2(g) + 4 H2O(l) ___ g H2O c. What mass of oxygen is required for this combustion? ___ g O2 d. If 0.1599 moles of propane and 0.6243 moles of oxygen are sealed...
Suppose that Coca-Cola uses a new type of vending machine that charges a price according to...
Suppose that Coca-Cola uses a new type of vending machine that charges a price according to the outside temperature. On “hot” days—defined as days in which the outside temperature is 25 degrees Celsius or higher—demand for vending machine soft drinks is: Q = 300 − 2P . On “cool” days—when the outside temperature is below 25 degrees Celsius—demand is: Q =200 − 2P . The marginal cost of a canned soft drink is 20 cents. a. What price should the...
Tamarisk Gas Inc., an oil and gas company had the following information on its financial statements...
Tamarisk Gas Inc., an oil and gas company had the following information on its financial statements for the fiscal years ended December 31. All figures are in millions of dollars. 2021 2020 2019 2018 Total assets $9,510 $6,380 $2,997 $2,763 Total liabilities 5,842 2,697 2,169 1,684 Profit 1,390 461 35 285 Interest expense 109 74 58 50 Income tax expense (recovery) 603 222 (25) 178 A) Calculate Tamarisk’s (Round answers to 1 decimal place, e.g. 52.7 or 52.7%.) (1) Debt...
Bellamy Corporation uses customers served as its measure of activity. The company bases its budgets on...
Bellamy Corporation uses customers served as its measure of activity. The company bases its budgets on the following information: Revenue should be $3.20 per customer served. Wages and salaries should be $21,000 per month plus $0.80 per customer served. Supplies should be $0.70 per customer served. Insurance should be $5,300 per month. Miscellaneous expenses should be $3,100 per month plus $0.10 per customer served. The company reported the following actual results for October: Customers served 22,000 Revenue $ 73,300 Wages...
The following table shows some information on a hypothetical economy. The table lists real GDP, consumption...
The following table shows some information on a hypothetical economy. The table lists real GDP, consumption (C), investment (I), government spending (G), net exports (X – M), and aggregate expenditures (AE). In this problem, assume that investment, government spending, and net exports are independent of the economy's real GDP level. Using the numbers provided in the table, enter the correct numbers in the empty cells. Then, using the dropdown selection menus in the right-most column, indicate whether output will tend...
Suppose a monopolist charges a price of $27 for its product and sells 10 units at...
Suppose a monopolist charges a price of $27 for its product and sells 10 units at that price. At 10 units of production the firm has average fixed cost equal to $10 and average variable cost equal to $12. How much total profit is the firm earning at this price? (show your work)
In the market A the price a company charges per product is $ 20 and its...
In the market A the price a company charges per product is $ 20 and its marginal cost is $ 10. In market B, another company sells a product at $ 30 and its marginal cost is $ 20. i) Who has greater market power company A or company B? ii) If we now know that the elasticity of demand is -2 in the market A and -0.3 in the market B. Who has greater market power? Why?
Company A is considering the following two mutually exclusive projects. Company A bases their capital budgeting...
Company A is considering the following two mutually exclusive projects. Company A bases their capital budgeting decisions solely on the NPV criteria. (Do not round intermediate calculations. Round your final answer to two decimal places.) Year Project 1 Project 2 0 -$75,000 -$75,000 1 $50,000 $20,000 2 $30,000 $21,000 3 $15,000 $59,000 1. At what required rate of return (%) is Company A indifferent between the two projects? 2. If the required rate of return is less than the crossover...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT