Hey Guys,
This is my first post here, possibly my first of many after today. I am brand new to C#. I have a school assignment and I've been working on it for hours. I cannot figure it out. I'm not looking for the answers, just help.
Here's the assignment:
Form Specification:
- Use a label for the title of the club. Name it anything that you wish. Place it in the center and top of the form.
- Use labels to prompt the user for the input data and for the titles of the output results.
- Place a textbox across from each label, to input the data and output the results.
- Place a calculate button in between the input and output.
- Place a close button on the bottom right of the form.
- Put your name in a label positioned under the close button on the bottom right of the form.
Code Specification:
- In the calculate_Click event method:
a. Assign the input (i.e., number of tickets and price per ticket) from the textboxes to variables.
b. Call a void method named calcAmount to calculate the subtotal, the HST tax amount, and the total. Pass the arguments for number of tickets and price per ticket by value (i.e., the default); and pass the arguments for subtotal, the HST tax amount, and the total by reference.
c. Display the results by assigning the values to the appropriate textboxes.
- In the close_Click event method:
- Close the form.
- In the void method, calcAmount:
- Declare a constant variable for the HST amount and initialize it with the value 0.13.
- Calculate the subtotal, the HST tax amount, and the total (assigning the results to the parameters.)
Here's my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Assignment_2._2
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
double getSubTotal;
double getTax;
double getGrandTotal;
public MainWindow()
{
InitializeComponent();
}
private static void btnCalc_Click(object sender, RoutedEventArgs e)
{
// get textbox values
int numOfTix = int.Parse(txtNumOfTickets.Text);
double pricePer = double.Parse(txtPricePerTicket.Text);
}
private static void calcAmount(int numOfTix, double pricePer, ref double getSubTotal, ref double getTax, ref double getGrandTotal)
{
const double HST_SALES_TAX = 0.13;
double subTotal = numOfTix * pricePer;
double tax = subTotal * HST_SALES_TAX;
double total = tax + subTotal;
getSubTotal = double.Parse(subTotal.ToString());
getTax = double.Parse(tax.ToString());
getGrandTotal = double.Parse(total.ToString());
}
}}