Jump to content

Recommended Posts

Posted

Communication with the aliens

Objectives
The objectives of this work:
- Handling (declaration, initialization and conversion) of variables
- Understanding of digital and Boolean expressions
- Use select statements (if / else)
- Using loops

Presentation of the problem
You are hired by NASA that has just come into contact with extraterrestrials.
The aliens are trying to communicate with us by sending us numerical values, and
we reply.
We are familiar with the base 10, which is part of our daily lives. For IT
Off-pair that you are, the base 2 has no secrets for you. Similarly for
8 and hexadecimal bases, 16. But what happens if we express numbers in base 23, 34?

NASA asks you to make a program that allows the conversion of number in
base 10 numbers to other bases whatsoever. Your program will be called
Alien.java

Basic knowledge on converting numbers
What is a digital database?

Each number is written are expressed in a precise numerical basis, normally
base 10. If we express the number 14, expressed exactly does one?
Exponent of 10: 1 0
Number: 1 4
Thus, the number 14 comes from: 14 = 1_101 4_100
If we take another example, the number 1237, that number is expressed by the table
follows:
Superscript 10: 3 2 1 0
Quantity: 1 2 3 7
Thus, the number 1237 comes from: 1237 1_103 2_102 3_101 7_100 =
Thus, each number represents a form a multiplication factor of a
outlining its basic digital.
What happens if we want to express the number 17 (base 10) in the following basis:
- Base-2: 17 = (10001) 2 = 1_24 0_23 0_22 0_21 1_20
- Base 8 17 = (00 021) 8 = 0_84 0_83 0_82 2_81 1_80
- 16 base 17 = (00011) 0_164 0_163 0_162 16 = 1_161 1_160
Thus, the numbers change completely how to write, depending on the basis
digital is used.

The number of bits
The number of bits determines the number of digits will build the number you
want to write. For example, if you write 10-bit number 147, would give the results
following:
- In base 10: 0000 0147
- Base 2: 147 = (10010011) 2
- Base 8: 147 = (00000223) 8
- In base 16: 147 = (00000093) 16

What if the number to enter in a bit over 9?
You're already familiar with the base 16, hexadecimal. The value for each
positions in the base hexadecimal numbers can be between 0 and 15. Unfortunately
you can not write a single position values 10,11,12,13,14 and 15 (since they are
composed of two numbers). In the case of the base 16, it uses numbers and letters
following, to express the values:

Values: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Corresponding character: 0 1 2 3 4 5 6 7 8 9 ABCDEF
So if you want to write the number 250 in base 16 with 3 bits, obtains the following number:
(250) 10 = (0FA) 16 162 15 = 0 _ _ _ 161 10 160
F = 0 _ 162 _ 160 _ 161 A
So, in your program, you must express the values above 10 with
letters, not figures.
4 Operation of your program
You should write a program that performs the following steps
1. Ask the user an nb, POSITIVE and base 10, it wishes to convert
2. Prompts the user base into which convert the numbers nb
3. Prompts the user with how many bits it wants to write the number
4. Print the number converted in its new base, with the desired number of bits
Your program will convert the numbers selected by the user until the latter
between a negative number. In this case, you record a message telling the user
communication with the aliens ended ... :) You do not have to
convert negative numbers.

Example execution
Here is an example of running your program:

Enter the number to be converted
147
Enter the base conversion (between 2 and 41)
16
Enter the number of bits encoding
8
The number converted:
00000093
Enter the number to be converted
18
Enter the base conversion (between 2 and 41)
14
3
Enter the number of bits encoding
4
The number converted:
0014
Enter the number to be converted
48
Enter the base conversion (between 2 and 41)
2
Enter the number of bits encoding
10
The number converted:
0000110000
Enter the number to be converted
-1

Communication ended

5 Restriction to User
Checks should be made to verify that the user input are
valid:

The bases selected by the user should be between 2 and 35, in order to express
numbers with numbers from 0-9 and from A to Z.

The number to be translated should be expressed in the number of bits requested by the user.
If one of above conditions is not met, your program must indicate to the user via an error message that the entry is invalid.

Here's an example:

Enter the number to be converted
100
Enter the base conversion (between 2 and 41)
2
Enter the number of bits encoding
3

Unable to express the number 100 in 3 digit

Enter the number to be converted
100
Enter the base conversion (between 2 and 41)
59
The base is invalid
4

You can assume that the user will always enter the whole ...

Criteria for termination of your program (stops when a negative number is entered)

Here's what you must submit:
- Your pseudo-code (Required)
- Your code, which will be in the file: Alien.java

Put the answer on the forum (The pseudo-code and code Java)

 

Pour la version francaise, veuiller downloader le document si dessous:

http://aezir.com/download/Alien.doc

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • Well, I made this. So if you want to create a talent system design you can always dm me. You can find my contact info here 🙂  
    • como vamos conseguir ler esse arquivos pra salvar ?  
    • DISCORD : https://discord.com/users/325653525793210378 utchiha_market telegram : https://t.me/utchiha_market SELLIX STORE : https://utchihamkt.mysellix.io/ Join our server for more products : https://discord.gg/uthciha-services https://campsite.bio/utchihaamkt
    • Eldamar Don't tell me what to do, stop spamming and mind your own business, it's 2025, who's going to play your server like it's 2007, you're ridiculous.
    • New Season Koofs Vs Noobs Get ready for the return of the epic Lineage II experience! L2KvN is coming back stronger than ever, featuring thrilling PvP, powerful factions, and unforgettable gameplay! Whether you're new to the world of L2KvN or returning to conquer it once more, there’s something for everyone:   Global Launch Times Mark your calendars! The server will launch at the following times around the world 20:00 Greece (Athens) GMT +2  20:00 Russia (Moscow) GMT +3 00:00 Russia (Novosibirsk) GMT +7 05:00 Russia (Vladivostok) GMT +10 14:00 Brazil GMT -3 13:00 Argentina GMT -3 20:00 Lithuania GMT +2 18:00 United Kingdom GMT 0 13:00 USA (Eastern Time) GMT -5 10:00 USA (Pacific Time) GMT -8   L2KvN server is with high rates and custom features. Offers fast progression and an exciting experience. Perfect for fans of intense gameplay.   Server Chronicles Interlude Rates: PvP(High) Adena: x1(Custom) Drop Rate: x1(Custom) 1 PvP = 2 Adena(4 For Premium Users)   Premium Account can be activated by purchasing Premium Account Coupon from L2Store and double-clicking the coupon. Premium Account provides the following: 1 PvP: 4 Adena   General Rates Start up Player System Instant LvL 80 Choose For What Faction You Love To Fight [Koofs - Noobs] Koofs Base: Dark Elf Village Noobs Base: Elven Village Prepare You Character Scheme Buff Or Choose Auto Buff PrePare Your Character Equipment From KvN Shop Killing spree systems Full GM shop. Free class change and Subclass All NPCs available in town. Custom Items Balanced. Community Board BugReport/RaidInfo/TopPvP-Online 1 PvP = 1 Adena (2 If Premium)   Enchant Rates Safe Enchant +6 Max Enchant +21 Normal Scroll Chance: 100% (+0 to +6) Blessed Scroll Chance: 85% (+6 to +21) Ex: If +14 failed for +15, return +14   LifeStone Rates High Lifestone Chance: 5% Top Lifestone Chance: 10%   Grand Bosses Queen Ant 8H +1Random (there is a chance to spawn in 7H or 9H) Drops RB Ring/LS/BOGS Baium 8H +1Random (there is a chance to spawn in 7H or 9H) Drops RB Ring/LS/BOGS Zaken 8H +1Random (there is a chance to spawn in 7H or 9H) Drops RB Ring/LS/BOGS Antharas 8H +1Random (there is a chance to spawn in 7H or 9H) Drops RB Ring/LS/BOGS Valakas 8H +1Random (there is a chance to spawn in 7H or 9H) Drops RB Ring/LS/BOGS   Elo Ranking System start unranked and ranks is Unranked-Iron-Bronze-Silver-Gold-Platinum-Diamond All ranks have 3 rank example Iron III Iron II iron I (iron iii is first and iron i is last. you need iron 1 to upgrade to silver.) unranked to iron need 50 points. and all ranks need 100 points to up a rank 5 points per kill if you die you lose 3 points. if you demote (have 4 points and die and you silver i you will demote to bronze iii 20 points.) if you bronze i 99 points and got 1 kill (+5 points) you uprank to silver iii 20 points. every rank have berets. see in video berets in ranks Iron/Bronze/Silver/Gold/Platinum/Diamond (only visual no extra buffs)   PvP Zone System maps change every 1 hour Orc Village Gludin Town   Event System Events every 1 hour TeamVsTeam => 12:00 14:00 16:00 18:00 20:00 22:00 23:59 02:00 04:00 06:00 08:00 10:00 12:00 Capture The Flag => 13:00 15:00 17:00 19:00 21:00 23:00 01:00 03:00 05:00 07:00 09:00 11:00 Rewards = MvP 5 Events | Winner Team 10 Events | Looser 5 Events   🌐 Website: https://l2kvn.com/ 🌐 Website: https://discord.gg/unn2XBhwef
  • Topics

×
×
  • Create New...