Sie sind auf Seite 1von 4

Brandon Mitchell

INFO 1112 S11


Assignment 3

Page 390: Programming Problem Retail Price Calculator

November 6th 2016

Retail Price Calculator


Description:
This program will take the Wholesale price of a(n) item(s) and calculate the retail
price.

Input:
User inputs Items wholesale cost and markup percentage.
User can press Calculate and Exit Buttons.

Output:
The Program will display the Retail Price of the Item(s).

Source Code:
/*
Project: Retail Price Calculator
File: Form1.cs
Name: Brandon Mitchell
Section: S11
Date Written: November 1st 2016
Purpose: Calculates the Retail Price of a purchase.
*/

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

//The CalculateRetail Method will be called to calculate the retail price.


private decimal CalculateRetail(decimal wholesalePrice, decimal markupPercentage)
{
return wholesalePrice * markupPercentage;
}

private void calculateButton_Click(object sender, EventArgs e)


{
//Declaring the Variables
decimal wholesalePrice, markupPercentage, retailPrice;

//Validate the Cost Text Box


if (decimal.TryParse(costTextBox.Text, out wholesalePrice))
{
//Validate the Markup Text Box
if (decimal.TryParse(markupPercentTextBox.Text, out markupPercentage))
{
//Calculate MarkUp Percentage.
markupPercentage = markupPercentage / 100;
//Call on CalculateRetail Method.
retailPrice = CalculateRetail(wholesalePrice, markupPercentage);

//Determine Final Retail Price.


retailPrice = retailPrice + wholesalePrice;

//Display Final Price to the user.


retailPriceLabel.Text = retailPrice.ToString("c");
}

else
{
MessageBox.Show("Enter a Valid Number.");
}
}

else
{
MessageBox.Show("Enter a Valid Number.");
}
}

private void exitButton_Click(object sender, EventArgs e)


{
//Close the Form.
this.Close();
}
}
}

Retail Price Calculator Running


When the user starts the program, they will be prompted to enter the Item(s)
wholesale price and the markup percentage.

Once the User fills out the fields, they can press Calculate to generate the
Retail Price.
If the user enters a character other than a number, an Error Message will be
displayed.

When the User has finished using the program, they may select the Exit
button in order to close the program.

Das könnte Ihnen auch gefallen