Converts the person''s favourite color,gender into number

Assignment Help Game Theory
Reference no: EM13944911

The program asks the user four questions. It converts the person's favourite color, person's gender and person's level of education into a corresponding number. Finally a lucky number is generated based on a mathematical expression using these numbers.

Can you please modify my program so that it employs two classes: a "Driver" class (that contains the main method) and another class called "Lucky" that implements the operations seen in the original program.Note: I want the program to perform the exact same tasks as it does now (when the user runs the program). I just want my code modified so that it has two classes now.

One approach I have figured out is:

class Driver
{
public static void main (String [] args)
{
Lucky generator = new Lucky ();
generator.start();
}
}

With this approach the main loop for the program is contained in the "start" method of class Lucky.Furthermore, the calls to the different methods of class Lucky won't be made in the main method of the Driver class but instead will be made in the start method of class Lucky:
class Lucky
{
public void start ()
{
int ageModifier;
int colorModifier;
ageModifier = generator.determineAgeModifier ();
colorModifier = generator.determineColorModifier();
etc.
// The loop that asks the user if they want to re-run the program will be in method start and it will encompass all
// the calls to the methods of class Lucky.
}

public int determineAgeModifier ()
{
: :

return ageModifier;
}

: : : :

}

Here is an outline of the methods that you could implement in class Lucky:

1. public int determineAgeModifier (): This method prompts the user to enter his or her age. This value is stored in an integer and returned back to the caller of this method.

2. public int determineColorModifier (): This method prompts the user to enter his or her favourite primary color. Based on the value entered, the program will then determine the numeric value for the color modifier and return this value back to the caller of the method.

3. public int determineGenderModifier (): This method prompts the user to enter his or her gender. Based on the value entered, the program will then determine the numeric value for the gender modifier and return this value back to the caller of the method.

4. public int determineEducationModifier (): This method prompts the user to enter his or her current level of education (if the person is currently a student) or the highest level of education that he or she completed (if the person is no longer a student). Based on the value entered, the program will then determine the numeric value for the education modifier and return this value back to the caller of the method.

5. public int generateLuckyNumber (int ageModifier, int colorModifier, int genderModifier, int educationModifier): The parameters to this method are the four numeric modifiers that were generated by the previous four methods. Method generateLuckyNumber applies the formula outlined in the first assignment in order to calculate the largest lucky number. A call is in made to class Random (or some other class that generates random numbers) in order to generate a lucky number from zero to this maximum value. The lucky number is returned to the caller of generateLuckyNumber.

6. public void display (int luckyNumber): This takes the lucky number generated by the previous method (#5) and displays it to the onscreen along with whatever formatting statements that you wish to add.

I want this program to be able to compile and run on my computer. I use UNIX and compile my programs with javac filename.java (javac compiler). The UNIX file is then changed from something.java to something.class. To run the interpreter, in UNIX I type java filename.

Attachment:- ass1cpsc5.zip

Reference no: EM13944911

Questions Cloud

Maximum cost nally would be willing to pay for project : Nally, Inc., is considering a project that will result in initial aftertax cash savings of $6.1 million at the end of the first year, and these savings will grow at a rate of 3 percent per year indefinitely. Calculate the WACC. What is the maximum co..
Principles that promote human flourishing : Analyse the issue in terms of the common good and the principles that promote human flourishing. (750 words).
Can you share an example of an internal control : What are some internal controls in place at your organization? Can you share an example of an internal control failure at your organization? Why did this failure occur?
Calculate the revenue for units sold : Below is the profit model spreadsheet for a shoe manufacturer in the month of January. 1) Calculate the revenue for units sold.
Converts the person''s favourite color,gender into number : The program asks the user four questions. It converts the person's favourite color, person's gender and person's level of education into a corresponding number. Finally a lucky number is generated based on a mathematical expression using these num..
Standard vehicles to hybrid vehicle production : An automobile manufacturer is converting an assembly line from standard vehicles to hybrid vehicle production. Conversion will cost $100 million. If the interest rate is 15%, how many years will it take until the present worth of the net benefits equ..
Organisations structure and culture : Explain the relationship between an organisation's structure and culture and the effects both culture and structure has on an organisation's performance.
Identify and thoroughly describe the factors : Identify and thoroughly describe the factors that led to American involvement in World War I.
What is the required rate of return on firms equity : Johnson Inc has 2,000 bonds and 300,000 shares of common stock outstanding. The common stock has a beta of 1.3 and trades at $18 per share . The firm is in 40% tax bracket. The market risk premium is 6% and yield on 10 year U.S. treasuries is 4%. The..

Reviews

Write a Review

Game Theory Questions & Answers

  Use the best-response approach to find all nash equilibria

Player 1 has the following set of strategies {A1;A2;A3;A4}; player 2’s set of strategies are {B1;B2;B3;B4}. Use the best-response approach to find all Nash equilibria.

  A supplier and a buyer, who are both risk neutral

A supplier and a buyer, who are both risk neutral, play the following game,  The buyer’s payoff is q^'-s^', and the supplier’s payoff is s^'-C(q^'), where C() is a strictly convex cost function with C(0)=C’(0)=0. These payoffs are commonly known.

  Pertaining to the matrix game theory problem

Pertaining to the matrix need simple and short answers, Find  (a) the strategies of the firm (b) where will the firm end up in the matrix equilibrium (c) whether the firm face the prisoner’s dilemma.

  Nash equilibria

Consider the two-period repeated game in which this stage game is played twice and the repeated-game payo s are simply the sum of the payo s in each of the two periods.

  Find the nash equilibrium

Two players, Ben and Diana, can choose strategy X or Y. If both Ben and Diana choose strategy X, every earns a payoff of $1000.

  Construct the payoff matrix for the game

The market for olive oil in new York City is controlled by 2-families, Sopranos and Contraltos. Both families will ruthlessly eliminate any other family that attempts to enter New York City olive oil market.

  Question about nash equilibrium

Following is a payoff matrix for Intel and AMD. In each cell, 1st number refers to AMD's profit, while second is Intel's.

  Finding the nash equilibrium

Determine the solution to the given advertising decision game between Coke and Pepsi, assuming the companies act independently.

  Nash equilibria to determine the best strategy

Little Kona is a small coffee corporation that is planning entering a market dominated through Big Brew. Each corporation's profit depends on whether Little Kona enters and whether Big Brew sets a high price or a low price.

  Creating a payoff table

Suppose you and your classmate are assigned a project on which you will earn one combined grade. You each wish to receive a good grade, but you also want to avoid hard work.

  Determine the nash equilibrium for trade policy

Consider trade relations in the United State and Mexico. Suppose that leaders of two countries believe the payoffs to alternative trade policies are as follows:

  Find the nash equilibrium outcomes

Use the given payoff matrix for a simultaneous move one shot game to answer the accompanying questions.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd