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

  Meet a reliability requirement

where time is measured in months and 0

  Various models of rental cars

Gasoline prices above $ 3 per gallon have affected what Enterprise Rental Car Co. can charge for various models of rental cars.

  Find a payoff function consistent with the information

If so, find a payoff function consistent with the information. If not, show why not. Answer the same questions when, alternatively, the decision-maker prefers the lottery.

  Explain how payoff matrices used in game theory

Explain how payoff matrices used in Game Theory illustrate mutual interdependence among firms in oligopolies. How can they be used to predict likely outcomes?

  1 if the four-firm concentration ratio of an industry is 75

1. if the four-firm concentration ratio of an industry is 75 what does it mean?2. industry a is composed of five large

  Lottery game played by choosing four numbers

A certain lottery game is played by choosing four numbers from 1 to 15 (no repetition of numbers;order of the numbers does not matter).

  Find the unique nash equilibrium of the game

Find the unique Nash equilibrium of the game in Table,and explain it

  Explain from firm as perspective the expected decision

Explain from firm A's perspective the expected decision that firm B will make and does situation have a Nash Equilibrium?

  Density curve describing the distribution

In order to answer the following questions, first draw a density curve describing this distribution. Pay attention to the height of the curve!

  Identify any dominant strategies in the game

Illustrate this game in a game table. Identify any dominant strategies in the game and solve for the Nash equilibrium.

  Show that the game has a mixed strategy nash equilibrium

Show that the game has a mixed strategy Nash equilibrium in which each player chooses each positive integer up to K with probability 1/K.

  Identifying a dominant strategy

Ken and Gerard are roommates for a weekend and have succeeded in making their living quarters cluttered in very little time.

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