Question: use this: static List roundPricesToMatchTarget(List prices, int target){ } DONT USE A [public static void main], MY MAIN ONLY THROWS IO EXCEPTION. Aou could imagine

 use this: static List roundPricesToMatchTarget(List prices, int target){ } DONT USE

use this:

static List roundPricesToMatchTarget(List prices, int target){

}

DONT USE A [public static void main], MY MAIN ONLY THROWS IO EXCEPTION.

Aou could imagine total reservation costs are computed from a base price and some fees and taxes. The base price may be an integer, but taxes and fees are percentage based, so the total amount could add up to be non-whole number. For example, base price 100, fee 2.3 and taxes 1.4 would lead to a net t, to be shown on our website, to be an integer. Given base price, fee and taxes, we would like to round them such that they add up to a desired total while minimizing the rounding error. More formally, we're going to solve the general case Given numbers prices [x,2,and target price target. We want to find a way to round each element in prices such that after rounding, we get rounded numbers rounded Prices y1 y2 y such that ylty2+ +y = target where yi-Floor or Ceil x floor or ceiling of x e also want to minimize the rounding error en by the sum, 2 Ix -yl for 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!