Write a program Ticket.java that will allow the user to enter actual speed limit, the speed limit at which the offender was travelling, and the number of previous tickets that person has received. The application should calculate and display how many miles over the speed limit the offender was travelling, the cost of the speeding ticket, and the court cost. Use $10.00 as the amount to be charged for each mile per hour over the speed limit. The court cost should begin at $50.00 and increase by $20.00 for each subsequent offense up to the third offense (that will represent the maximum court cost.).
Expert Answer
Code:
Form1.cs
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 WindowsFormsApplication7
{
public partial class Form1 : Form
{
String a;
String b;
String c;
String lis;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
//Reading listbox input into string lis
lis = listBox1.Text;
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
// reading texbox input to a string variable a
a = textBox1.Text;
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
// reading textbox input into string b
b = textBox2.Text;
}
private void button1_Click(object sender, EventArgs e)
{
//button click actions
//convert to int from string
int act = Int32.Parse(a);
int off = Int32.Parse(b);
//calculating the increased speed
int c = off- act;
//calculating the fine
int d = c*10;
//int to string conversion
string over = c.ToString();
string cos = d.ToString();
//string input cheching from list box
String f = “First”;
String s = “Secnd”;
String t = “Third+”;
//Outputting the over sped abd ticket value
textBox3.Text = over;
textBox5.Text = cos;
//for court fine
if (lis.Equals(f))
textBox6.Text=”50″;
if (lis.Equals(s))
textBox6.Text = “70”;
if (lis.Equals(t))
textBox6.Text = “90”;
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
private void textBox5_TextChanged(object sender, EventArgs e)
{
}
private void label4_Click(object sender, EventArgs e)
{
}
private void textBox6_TextChanged(object sender, EventArgs e)