Question

In: Computer Science

1. Complete Programming Problem #14, Stadium Seating, on page 199 of the textbook. A revised form...

1. Complete Programming Problem #14, Stadium Seating, on page 199 of the textbook. A revised form (original form provided in Figure 3-49) is provided below based upon theAdditional Requirements. Data is also provided to test the application.

The ADDITIONAL REQUIREMENTS described below MUST also be implemented:

  • Apply the currency format string for displaying monetary output (i.e., displays a leading currency symbol, digits, comma separators, and a decimal point)
  • Apply the number format string for displaying non-monetary output with no decimal places (i.e., the precision must be specified)
  • Implement simple exception handling to catch any exceptions that are thrown and display the exception's default error message
  • Implement named constants where applicable (i.e., the cost of the different classes of seats)
  • Calculate the total tickets sold for each individual transaction
  • Implement the following fields:
    • Sum of revenue which accumulates the overall revenue (i.e., running sum of the Total Revenue)
    • Sum of Tickets which accumulates the total tickets (i.e., running sum of the Total Tickets)
    • Count of Transactions which counts the number of times the Calculate Revenue button is clicked (i.e., adding to the Count of Transactions)
  • Add the following Label controls to the form (Note: GroupBox controls are used to group the various TextBox and Label controls):
    • Total Tickets (descriptive and output)
    • Sum of Revenue (descriptive and output)
    • Sum of Tickets (descriptive and output)
    • Transactions (descriptive and output

This the instructions for my class and I am lost. Here is my code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _3333_SilmonD_Lab03
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
  

private void calRevButton_Click(object sender, EventArgs e)
{
double CATickets;
double CBTickets;
double CCTickets;
double totalRevenue;


  

if (classATicketsTextBox.Text != "" && classBTicketsTextBox.Text != "" && classCTicketsTextBox.Text != "")
{
CATickets = double.Parse(classATicketsTextBox.Text);
CBTickets = double.Parse(classBTicketsTextBox.Text);
CCTickets = double.Parse(classCTicketsTextBox.Text);

CATickets = CATickets * 15.0;
CBTickets = CBTickets * 12.0;
CCTickets = CCTickets * 9.0;

totalRevenue = CATickets + CBTickets + CCTickets;
  
classARevenueTextBox.Text = CATickets.ToString("c");
classBRevenueTextBox.Text = CBTickets.ToString("c");
classCRevenueTextBox.Text = CCTickets.ToString("c");
totalRevenueTextBox.Text = totalRevenue.ToString("c");
sumofRevenueTextBox.Text = totalRevenue.ToString("c");
  
}
}

private void clearButton_Click(object sender, EventArgs e)
{
classATicketsTextBox.Text = "";
classBTicketsTextBox.Text = "";
classCTicketsTextBox.Text = "";
classARevenueTextBox.Text = "";
classBRevenueTextBox.Text = "";
classCRevenueTextBox.Text = "";
totalRevenueTextBox.Text = "";
}

private void exitButton_Click(object sender, EventArgs e)
{
this.Close();
}

private void sumofRevenueTextBox_TextChanged(object sender, EventArgs e)
{

}

private void totalTicketsBox_TextChanged(object sender, EventArgs e)
{

}
}
}

Solutions

Expert Solution

Visual C # windows application for Stadium seating cost and revenue:

Step1:

Design the form with controls group box, labels, text boxes and buttons as shown below

Step2:

Set the properties of the controls using the below table

Step3:

Source code :

//Source code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace StadiumSeating
{
public partial class Form1 : Form
{
//declare static variables for to accumulate the transactions count
//total revenue and total tickets
private static int transactions = 0;
private static double toral_revenue = 0;
private static double total_tickets = 0;

public Form1()
{
InitializeComponent();
}

private void calRev_Click(object sender, EventArgs e)
{
//increment the transactions by 1
transactions = transactions + 1;
//Set constants for class A , class B and class C tickets cost
const double CLASS_A_COST = 15.0;
const double CLASS_B_COST = 12.0;
const double CLASS_C_COST = 9.0;
//Set A,B and C tickets to 0
int CATickets=0;
int CBTickets = 0;
int CCTickets = 0;
int totalTickets = 0;
//Set revenues of class A,B and C to 0
double classARevenue = 0;
double classBRevenue = 0;
double classCRevenue = 0;
double revenue = 0;
  
//Use try-catch block for invalid input
try
{
CATickets = int.Parse(classATicketstextBox.Text);
CBTickets = int.Parse(classBTicketstextBox.Text);
CCTickets = int.Parse(classCTicketstextBox.Text);


//Sum class A , class B and class C tickets
totalTickets = CATickets + CBTickets + CCTickets;
//accumulate the total tickets
total_tickets = total_tickets + totalTickets;
totalTicketsLabel.Text = totalTickets.ToString();

//calculate the class A, B and C revnues
classARevenue = CATickets * CLASS_A_COST;
classBRevenue = CBTickets * CLASS_B_COST;
classCRevenue = CCTickets * CLASS_C_COST;

//Set revenues of each class type
classARevenueTextBox.Text = classARevenue.ToString("C2");
classBRevenueTextBox.Text = classBRevenue.ToString("C2");
classCRevenueTextBox.Text = classCRevenue.ToString("C2");

//set revenue , total revenue
revenue = classARevenue + classBRevenue + classCRevenue;
totalRevenueLabel.Text = revenue.ToString("C2");

//Accumlate total revenue
toral_revenue = toral_revenue + classARevenue + classBRevenue + classCRevenue;

//Set total revenue, total tickets and transactions
sumofRevenueLabel.Text = toral_revenue.ToString("C2");
sumofTicketsLabel.Text = total_tickets.ToString("C2");
transactionsLabel.Text = transactions.ToString();

}
//Catch blcok
catch (Exception exception)
{
MessageBox.Show(exception.Message);
}
}
/*Double click the clear button and write below code to clear all the fields the window*/
private void clearButton_Click(object sender, EventArgs e)
{

classATicketstextBox.Text = "";
classBTicketstextBox.Text = "";
classCTicketstextBox.Text = "";

classARevenueTextBox.Text = "";
classBRevenueTextBox.Text = "";
classCRevenueTextBox.Text = "";

totalTicketsLabel.Text = "";
totalRevenueLabel.Text = "";

sumofRevenueLabel.Text = "";
sumofTicketsLabel.Text = "";
transactionsLabel.Text = "";
}

/*Double click the exit button and write below code to close the window*/
private void exitButton_Click(object sender, EventArgs e)
{
Form1.ActiveForm.Close();
}
}
}

Step4:

Save the application and run , press F5


Related Solutions

Problem I:10-55 from the textbook (revised to include additional research). The Morris Corporation is a very...
Problem I:10-55 from the textbook (revised to include additional research). The Morris Corporation is a very successful and profitable manufacturing corporation. The corporation just completed leasehold improvements of its corporate offices, primarily for its top executives. The president and founder of the corporation, Mr. Timothy Couch, is an avid collector of artwork and has instructed that the lobby and selected offices be decorated with rare collections of art. These expensive works of art were purchased by the corporation in accordance...
Creatine clearance Worksheet Refer to page 14 of your textbook for reference and calculations For each...
Creatine clearance Worksheet Refer to page 14 of your textbook for reference and calculations For each of these questions calculate the creatine clearance using the most appropriate method John Sanders DOB 4-17-91 Patient’s urine creatine- 569mg/day Patient’s plasma creatine- 3.69mg/dL Total volume-729ml/24 hours Debbie Renninger DOB 7-19-86 Patient’s urine creatine- 1179 mg/day Patient’s plasma creatine-5.79 mg/dL Total volume- 2253mL/24 hours Samantha Pierson DOB 8-25-76 Patient’s urine creatine- 1589 mg/day Patient’s plasma creatine- 7.73 mg/dL Total volume- 785mL/24 hours Wesley Matthews...
Using the Prelude to Programming book, complete Programming Challenge 2 on page 463. Save your file...
Using the Prelude to Programming book, complete Programming Challenge 2 on page 463. Save your file as LASTNAME_FIRSTNAME_M07HW2. (worth 15 points) Create a program that allows the user to input a list of first names into one array and last names into a parallel array. Input should be terminated when the user enters a sentinel character. The output should be a list of email addresses where the address is of the following form: [email protected]. please help!!!!
ACC 650 - REVISED PROBLEM 14-47 #1 Tipton One-Stop Decorating sells paint and paint supplies, carpet,...
ACC 650 - REVISED PROBLEM 14-47 #1 Tipton One-Stop Decorating sells paint and paint supplies, carpet, and wallpaper at a single-store location in suburban Des Moines. Although the company has been very profitable over the years, management has seen a significant decline in wallpaper sales and earnings. Much of this decline is attributable to the Internet and to companies that advertise deeply discounted prices in magazines and offer customers free shipping and toll-free telephone numbers. Recent figures follow. Paint and...
Rework problems 13 and 14 from section 2.4 of your textbook (page 81) about the bucket...
Rework problems 13 and 14 from section 2.4 of your textbook (page 81) about the bucket containing orange tennis balls and yellow tennis balls from which 5 balls are selected at random, but assume that the bucket contains 6 orange balls and 8 yellow balls. (1) What is the probability that, of the 5 balls selected at random, at least one is orange and at least one is yellow? equation editorEquation Editor (1) What is the probability that, of the...
Implement the Producer-Consumer Problem programming assignment at the end of Chapter 5 in the textbook using...
Implement the Producer-Consumer Problem programming assignment at the end of Chapter 5 in the textbook using the programming language Java instead of the described C code. You must use Java with Threads instead of Pthreads.A brief overview is below. This program should work as follows: The user will enter on the command line the sleep time, number of producer threads, and the number of consumer threads. One example of the Java application from the command line could be “java ProducerConsumer...
Complete Case Incident 1, Questions 9-28, 9-29, and 9-30 on page 316 in textbook. Explain how...
Complete Case Incident 1, Questions 9-28, 9-29, and 9-30 on page 316 in textbook. Explain how you can relate the assigned scripture reading to this exercise. Your responses should be submitted in a minimum 375-word essay. CASE INCIDENT 1 The Calamities of Consensus When it is time for groups to reach a decision, many turn to consensus. Consensus, a situation of agreement, seems like a good idea. To achieve consensus, groups must cooperate and collaborate, which ultimately produces higher levels...
Read the Richard’s Furniture Company case that starts on page 58 of the textbook (problem 11)...
Read the Richard’s Furniture Company case that starts on page 58 of the textbook (problem 11) and then describe how internal control could be strengthened at Richard’s. Richards Furniture company is a 15-store chain, concentrated in the southwest, that sells living room and bedroom furniture. Each store has a full-time manager and an assistant manager, who are paid on a salary basis. The cashiers and sales personnel typically work part-time and are paid an hourly wage plus a commission based...
Complete problem 4.53 in the textbook. Calculate what is asked for with the given Young’s modulus,...
Complete problem 4.53 in the textbook. Calculate what is asked for with the given Young’s modulus, but also assuming the floor is concrete, and if it is rubber. You may use Matlab or other tools for specific one-step mathematical functions. PROBLEM FOR 4.53 BELOW COPY AND PAST IMGUR LINK please https://imgur.com/a/AwoZljr
For Supply and Demand Analysis Due Week 2 Complete the following questions from your Textbook (page...
For Supply and Demand Analysis Due Week 2 Complete the following questions from your Textbook (page 75). For EACH question, please graph AND explain your graph in detail below. I encourage students to review the PPTX and review Chapter 3 in the text as well. Note: Students can use excel OR write on this page and either scan the document or take a picture and upload to the gradebook. Keep it simple! Section 1: Demand. Consider the market for cars....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT