All pastes #749945 Raw Edit

Miscellany

public text v1 · immutable
#749945 ·published 2007-10-26 01:58 UTC
rendered paste body
// Medical Supply Store
// Peter Astrug

#include <iostream>
#include <iomanip>
using namespace std;

int main(){

	// Variables
	int package, amount;
	double price, given, subtotal, balance, total;

	// Menu
	cout << "Medical Supply Store";
	cout << "\n1. Deluxe Scrub Tops at $19.99 each";
	cout << "\n2. Deluxe Scrub Pants at $22.99 each";
	cout << "\n3. Value Set $18.99 each";
	cout << "\nChoose one or mof the following or press any key to exit" << endl;
	cin >> package;

	// Validate package and assign price
	switch(package){

	case 1:
		price = 19.99;
		break;

	case 2:
		price = 22.99;
		break;

	case 3:
		price = 18.99;
		break;

	default:
		cout << "\nInvalid package selection, Program will now end\n";
		return 0;
	}

	// Ask for numbers of packages
	cout << "\nHow many packages do you want to buy? ";
	cout << "\n5% discount given for 3 or more of a single item";
	cin >> amount;
	if( amount < 0)	{
		cout << "\nInvalid package amount, Program will now end\n";
		return 0;}

	// Subtotal, Tax, and Total
	subtotal = (price * amount);
	cout << "\nYour subtotal is: $" << setprecision(2) << fixed << subtotal;
	cout << "\nThe tax rate is: 8%";
	total = subtotal + (subtotal * 0.08);
	cout << "\nYour total is: $" << setprecision(2) << fixed << total;

	// Ask for amount given
	cout << "\n\nAmount given? ";
	cin >> given;
	if( given < total)	{
		cout << "\nInvalid amount given, Program will now end\n";
		return 0;}

	// Balance
	balance = (given - total);
	cout << "\nYour balance is: $" << setprecision(2) << fixed << balance << endl;

	return 0;

}