<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">import CS99.*;

/**
 * Lab 3 -- CarpetBill program
 * Author: Michael Clarkson
 * NetID: mrc26
 * Date: 6/30/00
 */
class CarpetBill {

	public static void main(String[] args) {

		/////////////////////////////////////////////////////////////////
		// Variable declarations
		/////////////////////////////////////////////////////////////////
	
		// Units below are in square yards
		// Costs are in dollars
		
		String customerName;		// customer's full name
				
		int unitsPurchased;			// amount of carpet purchased in sq. yds.

		double carpetCostPerUnit;	// cost of carpet per sq. yd.
		double carpetCost;			// cost of carpet bought
		double carpetDiscount;		// amount of discount on carpet
		double carpetCharge;		// total charge for carpet

		double laborCostPerUnit;	// cost of labor per sq. yd.
		double laborCost;			// cost of labor for amount of carpet bought
		double floorPrepFee;		// cost to prepare floor
		double laborCharge;			// total charge for labor
		
		double salesTax;			// amount of tax on sale
		double totalCharge;			// total amount charged to customer
		
		// percent discount applied to carpet, e.g., 2.0 for a 2% discount
		double discountPercentage;	
		
		final double SALES_TAX_PERCENTAGE = 8.0;	// 8% sales tax
		
				
		/////////////////////////////////////////////////////////////////
		// Get all the input
		/////////////////////////////////////////////////////////////////
		
		// Print the header
		System.out.println("Cayuga Carpet Company Billing Program");
		System.out.println();
		
		System.out.print("Enter the customer's name: ");
		customerName = Console.readString();
		
		System.out.print("Enter the number of square yards purchased: ");
		unitsPurchased = Console.readInt();
		
		System.out.print("Enter the cost of the carpet per sq. yd.: ");
		carpetCostPerUnit = Console.readDouble();
		
		System.out.print("Enter the cost of labor per sq. yd.: ");
		laborCostPerUnit = Console.readDouble();
		
		System.out.print("Enter the floor preparation fee: ");
		floorPrepFee = Console.readDouble();
		
		System.out.print("Enter the customer's discount percentage: ");
		discountPercentage = Console.readDouble();
		
		
		/////////////////////////////////////////////////////////////////
		// Calculate bill
		/////////////////////////////////////////////////////////////////
		
		carpetCost = unitsPurchased * carpetCostPerUnit;		
		carpetDiscount = carpetCost * (discountPercentage / 100);
		carpetCharge = carpetCost - carpetDiscount;
		
		laborCost = unitsPurchased * laborCostPerUnit;
		laborCharge = laborCost + floorPrepFee;
		
		salesTax = carpetCharge * (SALES_TAX_PERCENTAGE / 100);
		
		totalCharge = carpetCharge + laborCharge + salesTax;
		
		
		/////////////////////////////////////////////////////////////////
		// Print bill
		/////////////////////////////////////////////////////////////////

		// Leave some space between the input and the bill
		System.out.println("\n\n\n");

		System.out.println("     Cayuga Carpet Company");
		System.out.println("-------------------------------");
		System.out.println();
		
		System.out.println("Customer: " + customerName);
		System.out.println("Amount purchased: " + unitsPurchased + " sq. yd.");
		System.out.println();

		System.out.println("Materials");
		System.out.println("\tCost per sq. yd.: " + formatCurrency(carpetCostPerUnit));
		System.out.println("\tCarpet cost: " + formatCurrency(carpetCost));
		System.out.println("\tDiscount: " + formatCurrency(carpetDiscount));
		System.out.println("\tCarpet charge: " + formatCurrency(carpetCharge));
		System.out.println();
		
		System.out.println("Labor");
		System.out.println("\tCost per sq. yd.: " + formatCurrency(laborCostPerUnit));
		System.out.println("\tLabor cost: " + formatCurrency(laborCost));
		System.out.println("\tFloor prep fee: " + formatCurrency(floorPrepFee));
		System.out.println("\tLabor charge: " + formatCurrency(laborCharge));
		System.out.println();
		
		System.out.println("Sales tax: " + formatCurrency(salesTax));
		System.out.println();
		
		System.out.println("Total charge: " + formatCurrency(totalCharge));

	}

	/**
	 * Yield a string containing the amount in the argument formatted 
	 * as currency in the default locale.
	 */
	static String formatCurrency(double amount) {
    	return java.text.NumberFormat.getCurrencyInstance().format(amount);
    }

}



</pre></body></html>