Win a copy of Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Erlang otp Task problem

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello everyone i try to learn Erlang otp programing and i have such a problem how to solve this task i try but i'm new and i don't have a good background on programing any suggestion!!


Implement a function that generates a random integer between 1 and 100. Then it reads an integer number from the standard input and checks whether the user given number is equal to the generated number. If not than it provides some hints to the user (similar to: "The number is lesser than ... ", "The number is greater than ...") and asks for a new number. The function asks numbers recursively until the user hits the generated one. To avoid infinite recursion a limit is provided as an initial argument, that is the maximum numbers of attempts. Please read the examples carefully to see what is the required information to provide for the user.

Example 1:

1> generate:num(20)

#########

Guess a number between 1 and 100!

--> 22.

22 is not my number. It is lesser than 22.

#########

Guess a number between 1 and 21!

--> 2.

2 is not my number. It is greater than 2.

#########

Guess a number between 3 and 21!

--> 5.

#########

Oh, yeah! 5 is my number! You've won the game!



Example 2:

1> generate:num(2)

#########

Guess a number between 1 and 100!

--> 55.

55 is not my number. It is lesser than 55.

#########

Guess a number between 1 and 54!

--> 21.

21 is not my number. It is lesser than 21.

#########

Game is over, sorry you've lost the game!
 
Where all the women are strong, all the men are good looking and all the tiny ads are above average:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic