TopCoder problem "ValueAddedTax" used in SRM 355 (Division II Level One)



Problem Statement

    

In Russia, the Value Added Tax is 18% for almost all goods, with the exception of certain food items, which have a Value Added Tax of only 10%.

You are given a String product, the name of a product, and an int price, the price of the product before tax. You are also given a String[] food, each element of which is the name of a food product. If the given product is an element in food, it is a food item (and thus subject to 10% tax), and otherwise, it is a non-food item (and thus subject to 18% tax). Return the price of the product after tax has been added.

 

Definition

    
Class:ValueAddedTax
Method:calculateFinalPrice
Parameters:String, int, String[]
Returns:double
Method signature:double calculateFinalPrice(String product, int price, String[] food)
(be sure your method is public)
    
 

Notes

-The returned value must have an absolute or relative error less than 1e-9.
 

Constraints

-product will contain between 1 and 50 characters, inclusive.
-Each character in product will be a lowercase letter ('a'-'z').
-price will be between 1 and 1000, inclusive.
-food will contain between 1 and 50 elements, inclusive.
-Each element of food will contain between 1 and 50 characters, inclusive.
-Each character in each element of food will be a lowercase letter ('a'-'z').
-All elements of food will be distinct.
 

Examples

0)
    
"milk"
1
{"bread", "butter", "milk"}
Returns: 1.1
1)
    
"car"
100
{"bread", "butter", "milk"}
Returns: 118.0
2)
    
"abc"
57
{"a", "b", "c"}
Returns: 67.25999999999999

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=7894

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=10712&pm=7894

Writer:

Petr

Testers:

PabloGilberto , brett1479 , Olexiy , marian

Problem categories:

Simple Math