Find Jobs
Hire Freelancers

Slot Machine

$30-35 USD

Em Andamento
Publicado há mais de 21 anos

$30-35 USD

Pago na entrega
Java Program (I use Blue J v 1.3.1): After successfully stealing thousands of francs you decide to retire and enjoy your ill-gotten gains. However, a few thousand francs will not last very long, so you decide to invest your money. Though you examine several high-yield mutual funds and low-risk stocks, you wisely decide to go to Las Vegas and spend it all on the slot machines of the Low Rollers Casino. To maximize your wealth, you decide to write a program (with 3 classes) that evaluates several slot machines and determines the slot machine with the highest payoff. Your program will use three classes. The first is InputReader . This will be used to read lines of input from the input file provided as a command line argument. The second class will be the SlotMachine class. This class will contain all the data necessary to describe a slot machine. In particular, it should contain the machine’s name, possible combinations, payoffs for each combination (given below), a pull() method that returns the payoff of a random combination (described in more information below), and cost for each pull(). This class will not contain a main method, but must contain a constructor. The third class will be the Assign4 class. This class will use the InputReader class to read lines of input from the input file. Each line of input describes one slot machine. For each line of input, this class will create a new SlotMachine object, pull() the handle 50 times, record the output of each pull(), and determine how much money overall would have been won or lost. After evaluating all of the slot machines, this class outputs the total number of machines evaluated and the name of the machine that provides the most money. ## Deliverables 1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done. 2) Installation package that will install the software (in ready-to-run condition) on the platform(s) specified in this bid request. 3) Complete ownership and distribution copyrights to all work purchased. COMBINATION PAYOFFS: Combination 1 2 3 4 5 6 7 8 9 10 Payoff $12 $4 $54 $2 $20 $17 $6 $20 $12 $11 THE PULL() METHOD: The pull() method randomly determines a combination (using [login to view URL]()) from 1 to 10. If the combination is not valid for that machine, it randomly determines another combination until it finds a valid one. It then uses the payoff table above to determine how much was won or lost on that pull. It returns an integer number representing how much was won or lost, minus the cost of the pull. For example, the slot machine LuckyDucky costs $5 per pull, and has a combination range of 3 to 10. The first pull finds a combination of 4, which is a payoff of $2. Since this machine costs $5, it returns -$3 ($2 - $5 = -$3). On the next pull, it finds a combination of 1. Since this falls outside of the valid combination range, it looks for another combination and finds 9, which has a payoff of $12. $12 minus $5 is $7, which it returns. Note: Keep calling the pull() method until you get 50 valid pulls. THE INPUT FILE: The input file will contain an unspecified number of input lines. Each line contains the slot machine name (you may assume it will be one word long – such as Lucky – or many words concatenated – such as LuckyDucky or Lucky_Ducky – so you need not worry about spaces inside of machine names), the cost of the machine, and two integer number representing the range of possible combinations. For example, take the input line: LuckyDucky 5 3 10 “LuckyDucky” is the name of the slot machine, “5” is the cost per pull, and “3” and “10” means the slot machine contains combination numbers 3 through 10. SAMPLE INPUT: LuckyDucky 5 3 10 Dubya Bush 4 3 Dubya_Bush 3 3 Dubya_Bush 3.3 4 5 SpruceGoose 2 1 5 Bubba_Gump 10 2 1 SAMPLE OUTPUT: (output numbers not necessarily correct) LuckyDucky ($5 per pull) Contains combinations 3 to 10 Wins a total of $50 Invalid input line ignored: Dubya Bush 4 3 Invalid input line ignored: Dubya_Bush 3 3 Invalid input line ignored: Dubya_Bush 3.3 4 5 SpruceGoose ($2 per pull) Contains combinations 1 to 5 Loses a total of $23 Bubba_Gump ($10 per pull) Contains combinations 1 to 2 Wins a total of $3 *** Results *** Evaluated 3 slot machines Most profitable: LuckyDucky, $50 ERROR CHECKING: Your program should include an error check of the number of inputs on a line and whether the inputs are valid and in the proper order. Invalid input lines should be ignored and an error message should be displayed with the invalid input line, such as the examples above. Note that the last line in the sample input is valid, even though “2” is greater and appears before “1”. INPUTS FOR PROGRAM SUBMISSION: The actual input file used during program submission will not be provided, but rather will be read automatically during the submission process. You should again make up your own input file to test your program. Include a variety of possible test cases to ensure that your program will handle any error included in the actual input file. ## Platform Windows 98 using Blue J vs 1.3.1 use InputReader: import java.io.*; /************************************** * This class opens a file for reading. * Usage Examples: * * // open a file named [login to view URL] * InputReader myFile = new InputReader("[login to view URL]"); * * // read a line from the file * String nextLine = [login to view URL](); **************************************/ public class InputReader { static BufferedReader file; public InputReader(String fileName) { try { file = new BufferedReader(new FileReader(fileName)); } catch(FileNotFoundException e) { [login to view URL]("Error! File not found!"); [login to view URL](0); } } public static String readLine() { try {return([login to view URL]());} catch(IOException e){return null;} } }
ID do Projeto: 2878386

Sobre o projeto

5 propostas
Projeto remoto
Ativo há 22 anos

Quer ganhar algum dinheiro?

Benefícios de ofertar no Freelancer

Defina seu orçamento e seu prazo
Seja pago pelo seu trabalho
Descreva sua proposta
É grátis para se inscrever e fazer ofertas em trabalhos
Concedido a:
Avatar do Usuário
See private message.
$17 USD em 14 dias
4,9 (20 avaliações)
3,3
3,3
5 freelancers estão ofertando em média $16 USD for esse trabalho
Avatar do Usuário
See private message.
$4,25 USD em 14 dias
5,0 (5 avaliações)
4,7
4,7
Avatar do Usuário
See private message.
$25,50 USD em 14 dias
4,7 (41 avaliações)
4,7
4,7
Avatar do Usuário
See private message.
$11,90 USD em 14 dias
4,9 (11 avaliações)
2,6
2,6
Avatar do Usuário
See private message.
$22,10 USD em 14 dias
4,8 (16 avaliações)
2,5
2,5

Sobre o cliente

Bandeira do(a) UNITED STATES
United States
4,5
1
Membro desde out. 22, 2002

Verificação do Cliente

Obrigado! Te enviamos um link por e-mail para que você possa reivindicar seu crédito gratuito.
Algo deu errado ao enviar seu e-mail. Por favor, tente novamente.
Usuários Registrados Total de Trabalhos Publicados
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Carregando pré-visualização
Permissão concedida para Geolocalização.
Sua sessão expirou e você foi desconectado. Por favor, faça login novamente.