Write a program to maximize use the grand fund if a teacher wants to buy three different types of lab equipment. Prompt the user to input all three different prices for the three types of equipment, the total amount of grand and the maximum of the remaining unused grand fund. Your output should be the amount of remaining grand and the numbers of each type of equipment the teacher can buy. Since the teacher wants to maximally use the grand, so the purchase arrangement with remaining grand greater than $0.10 will NOT be output. (Hint: use nested loop, you need to establish
the Math model before you start to programing)
Your input should look like:
Please enter the prices for the three equipments, grand of fund and limit of remaining fund: 9.95   6.75   12.95    2000    0.25
Your output should be comma separated and look like:
0.15, 11, 54, 37
0.21, 23, 15, 32
0.08, 38, 12, 26
This means the teacher can have options purchasing plans:
1) Buy 11 pieces of equipment 1, 54 pieces of equipment 2, 37 pieces of equipment 3, and the remaining unused grand fund is $0.15
2) Buy 23 pieces of equipment 1, 15 pieces of equipment 2, 32 pieces of equipment 3, and the remaining unused grand fund is $0.21
3) Buy 38 pieces of equipment 1, 12 pieces of equipment 2, 26 pieces of equipment 3, and the remaining unused grand fund is $0.08
4) ...
In addition, the teacher wants to maintain the three numbers of equipment purchasing in kind of "balanced" way, not differ too much, such as not differ more than 50. This means, for example, although the purchasing plan:
0.18, 8, 64, 27
Or, Buy 8 pieces of equipment 1, 64 pieces of equipment 2, 27 pieces of equipment 3, and the remaining unused grand fund is $0.18 meet the requirement of maximum use of grand fund, it should NOT be output since the difference of the purchasing equipment 1 and equipment 2 differs 56 pieces.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

* Math model:
* Loop over possible numbers of equipment 1 quantity:
*      Loop over possible numbers of equipment 2 quantity:
*          Loop over possible numbers of equipment 3 quantity:
*             Calculate total and remaining amounts
*             if remaining <= limit and equipment amounts are balanced:
*                  print remaining, equipment 1 quantity, equipment 2 quantity, equipment 3 quantity
public class MaximizeGrandFund {

    // Main method for program execution
    public static void main(String[] args) {
       // Construct Scanner for console input
       Scanner s = new Scanner(;
       // Construct variables
       double equipment1Price = 0.0;
       double equipment2Price = 0.0;
       double equipment3Price = 0.0;
       double grandFund = 0.0;
       double limit = 0.0...

By purchasing this solution you'll be able to access the following files:
Solution.PNG and

50% discount

$35.00 $17.50
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats