Code Monkey home page Code Monkey logo

clothespurchasechallange's Introduction

ClothesPurchaseChallange

A small challenge of cloths purchasing algorithms to be validated by the team. A customer wants to buy a pair of jeans, a pair of shoes, a skirt, and a top but has a limited budget in dollars. Given different pricing options for each product, determine how many options our customer has to buy 1 of each product. You can not spend more money than the budgeted amount.

Example

priceOfJean = [2,3] priceOfShoes = [4] priceOfSkirts = [2,3] priceofTops = [1,2]

The customer must buy shoes for 4 dollars since there is only one option. This leaves 6 dollars to spend on the other 3 items. Combination of prices paid for jeans, skirts, and tops respectively that add up to 6 dollars or fewer [2,2,2], [2,2,1], [3,2,1], [2,3,1].
There are 4 ways the customer can purchase all 4 items.

Functional Description Complete the getNumberOfOptions function in the editor below. The function must return an integer that represents the number of options present to buy the four items. getNumberOfOptions has 5 parameters:

List priceOfJeans : An integer array list that contains the price of the pairs of jeans available. List priceOfShoes: An integer array list that contains the price of the pairs of shoes available. List priceOfSkirts: An integer array list that contains the price of the skirts available. List priceOfTops : An integer array list that contains the price of the tops available. int dollars: The total number of dollars available to shop with.

import java.io.; import java.util.;

class Result { /** * Complete the 'getNumberOfOptions' function below. * The function is expected to return a LONG_INTEGER; * The function accepts following parameter: * 1.INTEGER_LIST priceOfJeans * 2.INTEGER_LIST priceOfShoes * 3.INTEGER_LIST priceOfSkirts * 4.INTEGER_LIST priceOfTops * 5.INTEGER dollars */

public static long getNumberOfOptions(List<Integer> priceOfJeans,
				List<Integer> priceOfShoes,
				List<Integer> priceOfSkirts,
				List<Integer> priceOfTops,int dollars)
{

	return ? ;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.