Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello I need help for this assignment: The assignment we will actually create a

ID: 3775914 • Letter: H

Question

Hello I need help for this assignment:

The assignment we will actually create a Windows Presentation Foundation (WPF) form.

The form should contain a text field to enter the amount of the meal. A list of checkboxes with Tip choices 10%, 15%, 20% and other. There should be a textbox for other.

The user will click a button to calculate the tip, and the total. In the code we will make a tax amount of .09 a constant. After the button is clicked the form will display the amount, the tip, the tax and the total.

Create a Class called "Bill." that has fields for Tip Percent and Amount and which has methods to calculate the Tip, Tax, and total.

Upload the code for the WPF Form and the bill class. Alternatively, upload all to GitHub and provide a link to the repository.

by using C# language.

Explanation / Answer

mainWindow.xaml

<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication1"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Label x:Name="labelAmount" Content="Amount :" HorizontalAlignment="Left" Margin="70,47,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="textBoxAmt" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" VerticalAlignment="Top" Width="120" Margin="155,51,0,0"/>
<CheckBox x:Name="checkBox10" Content="10%" HorizontalAlignment="Left" Margin="107,104,0,0" VerticalAlignment="Top"/>
<CheckBox x:Name="checkBox15" Content="15%" HorizontalAlignment="Left" Margin="107,135,0,0" VerticalAlignment="Top"/>
<CheckBox x:Name="checkBox20" Content="20%" HorizontalAlignment="Left" Margin="107,164,0,0" VerticalAlignment="Top"/>
<CheckBox x:Name="checkBoxOther" Content="Other :" HorizontalAlignment="Left" Margin="107,194,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="textBoxOther" HorizontalAlignment="Left" Height="23" Margin="175,192,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
<Button x:Name="ButtonCalculateTip" Content="Calculate Tip and Total" HorizontalAlignment="Left" Margin="84,246,0,0" VerticalAlignment="Top" Width="191" Click="ButtonCalculateTip_Click"/>
<Label x:Name="labelFinalAmount" Content="" HorizontalAlignment="Left" Margin="388,150,0,0" VerticalAlignment="Top"/>
<Label x:Name="labelFinalTax" Content="" HorizontalAlignment="Left" Margin="388,192,0,0" VerticalAlignment="Top"/>
<Label x:Name="labelFinalTip" Content="" HorizontalAlignment="Left" Margin="388,223,0,0" VerticalAlignment="Top"/>
<Label x:Name="labelFinalTotal" Content="" HorizontalAlignment="Left" Margin="388,266,0,0" VerticalAlignment="Top"/>
<Label x:Name="labelError" Content="" HorizontalAlignment="Left" Margin="351,47,0,0" VerticalAlignment="Top"/>
<Label x:Name="label" Content="Tip :" HorizontalAlignment="Left" Margin="53,98,0,0" VerticalAlignment="Top"/>

</Grid>
</Window>

---------------------------------------------

mainWindow.xaml.cs

using System.Windows;

namespace WpfApplication1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}

private void ButtonCalculateTip_Click(object sender, RoutedEventArgs e)
{
double amount = 0;
double.TryParse(textBoxAmt.Text.ToString(),out amount);
if (amount == 0) labelError.Content = "Invalid Amount";
double tipPercent = 0;
if (checkBox10.IsChecked.Value) tipPercent = 10;
if (checkBox15.IsChecked.Value) tipPercent = 15;
if (checkBox20.IsChecked.Value) tipPercent = 20;
if (checkBoxOther.IsChecked.Value) double.TryParse(textBoxOther.Text.ToString(), out tipPercent);
Bill b = new Bill();
labelFinalAmount.Content = "Amount:"+amount;
var tax = b.CalculateTax(amount);
labelFinalTax.Content = "Tax :"+ tax;
var tip = b.CalculateTip(amount, tipPercent);
labelFinalTip.Content = "Tip :" + tip;
labelFinalTotal.Content = "Total :" + b.CalculateTotal(amount, tip, tax);
}
}
}

----------------------------

Bill.cs

public class Bill
{
public double CalculateTip(double amount, double tipPercentage)
{
return (amount * tipPercentage) / 100;
}
public double CalculateTax(double amount )
{
return 0.09 * amount;
}
public double CalculateTotal(double amount, double tip, double tax)
{
return amount + tip + tax;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote