Question
Based on this program visual C# Modify project according to the requirements below Modify your existing application so that the final bill includes the gas
Based on this program visual C# Modify project according to the requirements below Modify your existing application so that the final bill includes the gas tax based on the user's state as follows: If the user enters the state of Michigan, then the tax amount is 0.26 cents per gallon. If a user enters the state Ohio, then the tax amount is 0.28 cents per gallon. For anything else, the tax amount is 0.48 cents per gallon. The final output should be exactly as follows: The price of a gallon of gas in Ypsilanti Michigan, is $x.xx (including 0.26 cents tax per gallon). It costs $x.xx to drive xxx miles. Also, add a checkbox to you form. If the box is checked, then the final amount will be rounded to the nearest dollar (i.e. 0 decimal spaces instead of 2 decimal spaces). Here is the Modify your existing application Code C# Program
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;
namespace GasBillApplication { public partial class Form1 : Form { public Form1() { InitializeComponent(); OutputLabel.Visible = false; }
//on button click private void button1_Click(object sender, EventArgs e) { //Variables initialization string city, state; double distance, pricepergallon,total; NumberFormatInfo setPrecision = new NumberFormatInfo(); setPrecision.NumberDecimalDigits = 2;
//if textboxes are not empty if (!txtDistance.Text.Equals("") && !txtCity.Text.Equals("") && !txtState.Text.Equals("") && !txtPrice.Text.Equals("")) { city = txtCity.Text; state = txtState.Text; distance = double.Parse(txtDistance.Text); pricepergallon = double.Parse(txtPrice.Text);
//calculate total price total = (distance/23.6)*pricepergallon;
OutputLabel.Visible = true;
//displaying result OutputLabel.Text = "The price of a gallon of gas in "+ city +" "+state+ ", is $"+pricepergallon+". It costs $"+total.ToString("N",setPrecision)+" to drive "+distance+" miles"; }
}
private void button2_Click(object sender, EventArgs e) { this.Close(); } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started