id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > orderSystemTotalPrice
prev  |  next  |  chance

Write a method that returns the total price of a bunch of items. Two arrays will be passed in. The 'quantity' array will indicate how many of a given item are being purchased. The 'price' array will indicate how much each of those items cost. The two arrays will have the same length, and the quantity will be paired with a cost at matching positions in the arrays. For example, passing in {5,2} to the quantity array and {100,1000} into the price array indicates that five $100 items are being purchased and two $1000 items are also being purchased. That makes the total price $2500, so return 2500. Prices will be in whole dollars (no cents). If the arrays are empty it means that nothing is being purchased so you should return zero.


orderSystemTotalPrice([5, 2], [100, 1000]) → 2500
orderSystemTotalPrice([], []) → 0
orderSystemTotalPrice([1, 1, 1, 1], [50, 10, 3, 6000]) → 6063

...Save, Compile, Run (ctrl-enter)

public int orderSystemTotalPrice(int[] quantity, int[] price) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 250

Copyright Nick Parlante 2017 - privacy