WPI Social Implications Of Computing
Course Documents
Assignments
Past
                                          
Printer Friendly Version
Test Sales Fun

Intro ] [ SalesFun-PlainTextCode.java ] [ SalesFun.java ] [ TestSalesFun.jar ]

Up: Assignments ]

package net.keithpray;

import java.text.NumberFormat;

public class SalesFun 
{ 
  public static double calculateSalesTotal ( 
		  double amount, 
		  double discountRate, 
		  double taxRate ) 
  { 
    double discount = amount * discountRate; 
    double total = amount - discount; 
    double tax = total * taxRate; 
    double taxedTotal = tax + total; 
    
    NumberFormat numberFormat = NumberFormat.getCurrencyInstance(); 
  
    System.out.println ( "Subtotal : " + numberFormat.format ( amount ) ); 
    System.out.println ( "Discount : " + numberFormat.format ( discount ) ); 
    System.out.println ( "Total : " + numberFormat.format ( total ) ); 
    System.out.println ( "Tax : " + numberFormat.format ( tax ) ); 
    System.out.println ( "Tax+Total: " + numberFormat.format ( taxedTotal ) ); 
    
    return taxedTotal;
  } 
}

Keith A. Pray
Last Modified: August 24, 2020 6:53 PM
© 2020 - 1975 Keith A. Pray.
All rights reserved.

Current Theme: 

Kapowee Hosted | Kapow Generated in 0.008 second | XHTML | CSS