CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

# Thread: C# Calculations Help

1. Junior Member
Join Date
Sep 2019
Posts
1

## C# Calculations Help

Hi. Im using Visual Studio 2019 leaning C#. I'm extremely new to the coding world and having a lot of trouble performing calculations. I would like someone to explain where I'm going wrong. I am not getting the prices to populate in the GUI when I click calculate. Ill attach the current code below.

Here's the assignment description.

For an upcoming concert, the Performing Arts Center (PAC) sells three classifications of seats – Class A (for \$18.50), Class B (for \$13.75) and Class C (for \$10.00). Create a C# application that allows the user to enter the quantity of seats sold for the performance. Upon clicking the “Calculate Revenue” button, the applications should display the revenue generated for each Class of seats (displayed as currency) and the three class summed together for the total revenue. Use GroupBoxes to separate the Input area (Tickets Sold) form the Output area (Revenue Generated). A Clear button should clear all the fields and put the cursor in the Class A entry textbox. The Exit button should close the application.

Code:
```double a, b, c, revA, revB, revC, tRev;
//input

a = int.Parse(txtTicketA.Text);
b = int.Parse(txtTicketB.Text);
c = int.Parse(txtTicketC.Text);
revA = int.Parse(txtRevA.Text);
revB = int.Parse(txtRevB.Text);
revC = int.Parse(txtRevC.Text);
tRev = int.Parse(txtTotalRev.Text);

//Multiply ticket by inputted amount

revA = a * 18.50;
revB = b * 13.75;
revC = c * 10.00;
tRev = revA + revB + revC;

txtRevA.Text = revA.ToString("N2");
txtRevB.Text = revB.ToString("N2");
txtRevC.Text = revC.ToString("N2");```
Last edited by 2kaud; September 12th, 2019 at 09:47 AM. Reason: Added code tags

2. ## Re: C# Calculations Help

You need to debug the cide. Put a break point in the calc revenue button, and press F5 to start debugging. Set the values and click the button. The code should stop on the breakpoint and allow you to inspect the values and single step through the code.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

Click Here to Expand Forum to Full Width