Question

In: Computer Science

C# A car dealer wants an application that calculates the cost of a car. The GUI...

C#

A car dealer wants an application that calculates the cost of a car.

The GUI application should link the “BuildYourCar.accdb” database and display all the data in four different “ListBox” based on the category. Each “ListBox” should display all the items in that category. The user can only choose one item from each “ListBox” to add an item to a car. As each item is selected, the application displays the item in a separate “ListBox” to display. If user wants to remove an item, the user can click the item in the display “ListBox” to remove it. When the item is selected, the cost of that item will be added to the subtotal. When the item is removed, the cost of that item will be subtracted.

The program should include Subtotal, Tax, and Total fields in the GUI. Also, the user can click the “Clear” Button to restore the Subtotal, Tax, and Total to $0.00.

Use the BuildYourCar.accdb database

Solutions

Expert Solution

Output:

Code will be like:

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 CarDealershipForm
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
//load items to the listbox from the database.
double price = 0;
string listBox1Item = listBox1.SelectedItem.ToString();
string listBox2Item = listBox2.SelectedItem.ToString();
string listBox3Item = listBox3.SelectedItem.ToString();
string listBox4Item = listBox4.SelectedItem.ToString();

//using the differnet items setup an ifelse statement to avaluate price and display
// it in the subtotal box.

if(listBox1Item=="Item 1 from listbox")
{
//Increment the price value accordingly
}
if (listBox1Item == "Item 2 from listbox")
{
//Increment the price value accordingly
}
if (listBox1Item == "Item 3 from listbox")
{
//Increment the price value accordingly
}

if (listBox2Item == "Item 1 from listbox")
{
//Increment the price value accordingly
}
if (listBox2Item == "Item 2 from listbox")
{
//Increment the price value accordingly
}
if (listBox3Item == "Item 3 from listbox")
{
//Increment the price value accordingly
}


// continue for all listboxes.

}
}
}

Designer:

namespace CarDealershipForm
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.listBox1 = new System.Windows.Forms.ListBox();
this.listBox2 = new System.Windows.Forms.ListBox();
this.listBox3 = new System.Windows.Forms.ListBox();
this.listBox4 = new System.Windows.Forms.ListBox();
this.listBox5 = new System.Windows.Forms.ListBox();
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// listBox1
//
this.listBox1.FormattingEnabled = true;
this.listBox1.Location = new System.Drawing.Point(31, 33);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(120, 95);
this.listBox1.TabIndex = 0;
//
// listBox2
//
this.listBox2.FormattingEnabled = true;
this.listBox2.Location = new System.Drawing.Point(199, 33);
this.listBox2.Name = "listBox2";
this.listBox2.Size = new System.Drawing.Size(120, 95);
this.listBox2.TabIndex = 1;
//
// listBox3
//
this.listBox3.FormattingEnabled = true;
this.listBox3.Location = new System.Drawing.Point(337, 33);
this.listBox3.Name = "listBox3";
this.listBox3.Size = new System.Drawing.Size(120, 95);
this.listBox3.TabIndex = 3;
//
// listBox4
//
this.listBox4.FormattingEnabled = true;
this.listBox4.Location = new System.Drawing.Point(489, 33);
this.listBox4.Name = "listBox4";
this.listBox4.Size = new System.Drawing.Size(120, 95);
this.listBox4.TabIndex = 2;
//
// listBox5
//
this.listBox5.FormattingEnabled = true;
this.listBox5.Location = new System.Drawing.Point(246, 225);
this.listBox5.Name = "listBox5";
this.listBox5.Size = new System.Drawing.Size(120, 95);
this.listBox5.TabIndex = 5;
//
// button1
//
this.button1.Location = new System.Drawing.Point(264, 164);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 6;
this.button1.Text = "Add";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(222, 368);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 7;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(116, 375);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(31, 13);
this.label1.TabIndex = 8;
this.label1.Text = "Total";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(635, 424);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.listBox5);
this.Controls.Add(this.listBox3);
this.Controls.Add(this.listBox4);
this.Controls.Add(this.listBox2);
this.Controls.Add(this.listBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.ListBox listBox2;
private System.Windows.Forms.ListBox listBox3;
private System.Windows.Forms.ListBox listBox4;
private System.Windows.Forms.ListBox listBox5;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1;
}
}

Please rate it if the above solution helps you in any way or if you have any concerns comment it, I will help you through again.


Related Solutions

In C# Create a GUI application that calculates and displays the total travel expenses of a...
In C# Create a GUI application that calculates and displays the total travel expenses of a business person on a trip. Here is the information that the user must provide: Number of days on the trip Amount of airfare, if any Amount of car rental fees, if any Number of miles driven, if a private vehicle was used Amount of parking fees, if any Amount of taxi charges, if any Conference or seminar registration fees, if any Lodging charges, per...
Create a GUI application in C# that calculates and displays the total travel expenses of a...
Create a GUI application in C# that calculates and displays the total travel expenses of a business person on a trip. Here is the information that the user must provide: • Number of days on the trip • Amount of airfare, if any • Amount of car rental fees, if any • Number of miles driven, if a private vehicle was used • Amount of parking fees, if any • Amount of taxi charges, if any • Conference or seminar...
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates...
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates and displays the total travel expenses of a business person on a trip. Here is the information that the user must provide: • Number of days on the trip • Amount of airfare, if any • Amount of car rental fees, if any • Number of miles driven, if a private vehicle was used • Amount of parking fees, if any • Amount of...
Create an application named Rusty2 that asks the user for the dealer cost of a car,...
Create an application named Rusty2 that asks the user for the dealer cost of a car, and the cleaning cost, and then displays the retail cost. Your application should simply send the dealer cost and cleaning cost to the getRetailPrice method in the Dealership class to obtain the retail cost. here below is the dealership class code amd meed to create rusty2 code import java.util.Calendar; public class Dealership { // public static final class variables public static final int YEAR_STARTED...
C++ application that calculates the sales at the end of the day. Need to know how...
C++ application that calculates the sales at the end of the day. Need to know how much money I made on selling my famous banana muffins each day. At the end of each day I must not only enter the number of banana muffins I sold but I must also enter the price of the banana muffins. Each day I have to experiment with changing the price in an attempt to maximize my revenues for his muffins. I also want...
A car dealer wants to use a software to display his or her cars’ information. As...
A car dealer wants to use a software to display his or her cars’ information. As a software developer, you are going to develop a simple program for the dealer. You will have a Car class which has the following member variables:  Car’s Brand  Car’s Color  Car’s MPG (Mile Per Gallon) This class has setters and getter for all member variables. This class has four different constructors: 1. A constructor with no argument. 2. A constructor with...
ASAP PLEASE Problem Statement A car dealer wants to use a software to display his or...
ASAP PLEASE Problem Statement A car dealer wants to use a software to display his or her cars’ information. As a software developer, you are going to develop a simple program for the dealer. You will have a Car class which has the following member variables:  Car’s Brand  Car’s Color  Car’s MPG (Mile Per Gallon) This class has setters and getter for all member variables. This class has four different constructors: 1. A constructor with no argument....
Problem Statement A car dealer wants to use a software to display his or her cars’...
Problem Statement A car dealer wants to use a software to display his or her cars’ information. As a software developer, you are going to develop a simple program for the dealer. You will have a Car class which has the following member variables:  Car’s Brand  Car’s Color  Car’s MPG (Mile Per Gallon) This class has setters and getter for all member variables. This class has four different constructors: 1. A constructor with no argument. 2. A...
You've been hired by Yogurt Yummies to write a C++ console application that calculates and displays...
You've been hired by Yogurt Yummies to write a C++ console application that calculates and displays the cost of a customer’s yogurt purchase. Use a validation loop to prompt for and get from the user the number of yogurts purchased in the range 1-9. Then use a validation loop to prompt for and get from the user the coupon discount in the range 0-20%. Calculate the following:         ● Subtotal using a cost of $3.50 per yogurt.         ● Subtotal...
How can we write an application that calculates connascence of an application?
How can we write an application that calculates connascence of an application?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT