From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7ba49aac4e73460 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.213.68 with SMTP id nq4mr7988588pbc.2.1329075621012; Sun, 12 Feb 2012 11:40:21 -0800 (PST) Path: wr5ni17202pbc.0!nntp.google.com!news1.google.com!postnews.google.com!m7g2000vbw.googlegroups.com!not-for-mail From: Will Newsgroups: comp.lang.ada Subject: Re: Need Help On Ada95 Problem Date: Sun, 12 Feb 2012 11:40:20 -0800 (PST) Organization: http://groups.google.com Message-ID: <43ebdc77-d90a-4213-8e74-db92ad373e14@m7g2000vbw.googlegroups.com> References: <553ceec3-ec34-41de-9723-0dc342379cfe@vv9g2000pbc.googlegroups.com> <4ea6309f-cf07-44f6-8c56-5189a0081dcc@g27g2000yqa.googlegroups.com> NNTP-Posting-Host: 134.240.18.64 Mime-Version: 1.0 X-Trace: posting.google.com 1329075620 2180 127.0.0.1 (12 Feb 2012 19:40:20 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 12 Feb 2012 19:40:20 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: m7g2000vbw.googlegroups.com; posting-host=134.240.18.64; posting-account=CZZpzgoAAAAoaHoNNp9zhY9EzQgEmxhU User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESNKRC X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111104 Red Hat/3.6.24-3.el6_1 Firefox/3.6.24,gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-02-12T11:40:20-08:00 List-Id: Here Is The Solution and it does work so all of you can understand. I am fairly new to Ada95 so I have not been introduced to Arrays and Case and all that stuff but I do understand the solutions here. I did use the ASCII table and if you view it and go through this by hand you will understand why it works. The solutions are as follows: with Ada.Text_IO; use Ada.Text_IO; with Ada.Characters.Handling; use Ada.Characters.Handling; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Strings.Fixed; use Ada.Strings.Fixed; procedure hw4 is function Encrypt(PIN : String) return String is -- Convert the 4-digit PIN to the corresponding 4-letter code. -- Assume PIN'Length is 4 and that all the characters in PIN are digits. -- Example: Encrypt("9537") = "ELVI" -- FILL IN FOUR MORE TEST CASES. --Test Case 1: Encrypt("6789") = "TINE" --Test Case 2: Encrypt("5432") = "LAVO" --Test Case 3: Encrypt("0926") = "UEOT" --Test Case 4: Encrypt("7359") = "IVLE" letterWheel : string := "UROVALTINE"; password : string := PIN; counter : integer := 1; number : Character := '0'; AdaIsHard : integer :=0 ; begin while counter <= 4 loop number:= password(counter); AdaIsHard := (Character'Pos(number)- 47); password(counter):= letterWheel(AdaIsHard); counter := counter + 1; end loop; return password; end Encrypt;