This program show how to calculate Car Rental using type of car, Km and Number of rental days. Insert that details and click Process Button then calculate total rental and Click Clear Button Clear all details for new One. When you click Exit button exit this program.
C#.net Code for Simple Car Rental Program
Download Source Project
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 CarRental
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void processButton_Click(object sender, EventArgs e)
{
decimal day, total,km;
day = decimal.Parse(daytextBox.Text);
km = decimal.Parse(kmtextBox.Text);
total = 0;
if (HondarButton.Checked)
{
total = (1500 + (20 * km)) - (80 * day);
}
else if (nissanrButton.Checked)
{
total = (2000 + (30 * km)) - (60 * day);
}
else if(civicrButton.Checked)
{
total = (2500 + (40 * km)) - (50 * day);
}
else
{
MessageBox.Show("Invalid Info");
}
totaltextBox.Text = total.ToString("c");
}
}
private void clear()
{
daytextBox.Clear();
kmtextBox.Clear();
totaltextBox.Clear();
HondarButton.Checked = true;
daytextBox.Focus();
}
private void exitButton_Click(object sender, EventArgs e)
{
this.Close();
}
private void clearButton_Click(object sender, EventArgs e)
{
clear();
}
}
}
6 comments
Posted at 2:08 AM |  by
Mit Guru






