Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Current code: public class Banker { public static MONEY_VALUES(){ } } import jav

ID: 3829216 • Letter: C

Question

Current code:

public class Banker {
    public static MONEY_VALUES(){
       
    }
}

import javax.swing.JOptionPane;

Banker class formula:

Formula The banker’s cash offer depends on the serial number of the current round and on the average of the contents of the non-eliminated briefcases. The formula used in a real life game is not public. In this model you have the following formula to apply:

N is the serial number of the round currently finished in the game (0 < N <10)

avg is the average of the dollar values in the remaining briefcases

temp = 0.01 *(75 + 5 * N – 3 * max(0, N -5)) * avg*(1+0.15*(avg-55000)/Math.abs(avg – 55000))

offer=Math.max(100,1000*Math.round(temp/1000))

Banker This class represents the banker. The banker knows the set of dollar values used in the game. The banker's only responsibility is to make offers to encourage the player to quit the game Fields MONEY VALUES Array of the dollar values, public static and constant, holds all the dollar values used in the game. Initialized at the declaration by an initializer list of values Methods makeOffer() static method. Takes two parameters: an int type for the serial number of the current round and a double value for the average of the dollar values in the remaining cases. The method computes and returns the offer to be made by the banker. The calculation is described above in the Formula section if Analysis Game Control This class controls game play. All methods exceptplay() are helper methods as such those must be declared private. Fields to hold a BriefcaseCollection object, instantiate it at declaration using the collection MONEY VALUES array from the Banker class for parameter Scanner object applied for obtaining input from the user to direct game play kb instantiate at declaration Methods choose ACase() Takes a BriefcaseCollection object collection for parameter and returns one of the briefcases from collection; the method l. calls showRemainingCases() w.r.t collection to display the serial numbers of the remaining briefcases 2. solicits a choice by the player from displayed serial numbers 3. saves the selected input in a local variable 4. runs a while loop to validate the input from the console (control the loop with the return value ofthe invalidChoice() method) 5. if input accepted, the choose ThisCase() method with the solicited number as parameter is called and the value is returned The double type parameter will be used for the banker's offer, the method make Deal() l. opens a confirm dialog (see Figure l below) to display the offer 2. The user clicks Yes to accept and No to reject the deal 3. Checks if the answer is equal to JOptionPane.YES OPTION and the boolean result is returned

Explanation / Answer


public class Briefcase
{
   double value;
   int serial;
  
   Briefcase(double val,int s)
   {
       value=val;
       serial=s;
   }
  
}

-------------------------------------


public class Banker {
  
  
   public static final double[] MONEY_VALUES={10,20,30,40};
  
   public static double makeOffer(double avg,int N)
   {
       double temp = 0.01 *(75 + 5 * N - 3 * Math.max(0, N -5)) * avg*(1+0.15*(avg-55000)/Math.abs(avg - 55000));
               double offer=Math.max(100,1000*Math.round(temp/1000));
  
   return offer;
   }

}

-----------------------------

import java.util.ArrayList;
import java.util.Scanner;

import javax.swing.JOptionPane;

public class GameControl {

   static ArrayList<Briefcase> collection =new ArrayList<Briefcase>();
   static Scanner kb=new Scanner(System.in);

   GameControl(double[] values)
   {
       for(int i=0;i<values.length;i++)
       {
           Briefcase b=new Briefcase(values[i],i);
           collection.add(b);

       }
   }

   private Briefcase chooseACase()
   {
       showRemainingCases();
       System.out.println("enter serial number you want to choose");
       int s=Integer.parseInt(kb.nextLine());

       while(InvalidChoice(s))
       {
           System.out.println("enter serial number you want to choose");
           s=Integer.parseInt(kb.nextLine());
       }

       return chooseThisCase(s);

   }

   private static Briefcase chooseThisCase(int s) {
       // TODO Auto-generated method stub
       return collection.remove(s);
   }

   private static void showRemainingCases()
   {

       for(int i=0;i<collection.size();i++)
       {
           System.out.println(collection.get(i).serial);
       }
   }

   private static boolean InvalidChoice(int s)

   {

       for(int i=0;i<collection.size();i++)

       {

           if(collection.get(i).serial==s)
           {
               return false;
           }

       }

       return true;

   }


   public boolean makeDeal(){

       JOptionPane.showConfirmDialog(null,"The offer is now " + " Click 'Yes' to "
               + "make a deal","Time for a decision: Deal or No Deal!",
               JOptionPane.YES_NO_OPTION);
       int confirm = 0;

       if(confirm == JOptionPane.YES_OPTION){
           return true;
       }
       else {

       }
       return false;
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote