comp.lang.ada
 help / color / mirror / Atom feed
From: Will <willmann817@gmail.com>
Subject: Re: Need Help On Ada95 Problem
Date: Sun, 12 Feb 2012 11:40:20 -0800 (PST)
Date: 2012-02-12T11:40:20-08:00	[thread overview]
Message-ID: <43ebdc77-d90a-4213-8e74-db92ad373e14@m7g2000vbw.googlegroups.com> (raw)
In-Reply-To: wccfweia1w9.fsf@shell01.TheWorld.com

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;



  reply	other threads:[~2012-02-12 19:40 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-09  1:03 Need Help On Ada95 Problem Will
2012-02-09  1:51 ` Robert A Duff
2012-02-09  2:01 ` Shark8
2012-02-10  1:36   ` BrianG
2012-02-10  2:22     ` Shark8
2012-02-10  5:32       ` Alex
2012-02-10 15:19         ` Shark8
2012-02-10 15:45           ` Alex
2012-02-10 20:07           ` Robert A Duff
2012-02-12 19:40             ` Will [this message]
2012-02-12 19:42               ` Will
2012-02-12 22:26               ` Robert A Duff
2012-02-13  0:41                 ` Will
2012-02-13  0:43                 ` Nasser M. Abbasi
2012-02-10  5:45       ` Alex
2012-02-10 13:29         ` Robert A Duff
2012-02-10 13:50           ` Alex
2012-02-10 14:30             ` Robert A Duff
2012-02-10 15:32               ` Alex
2012-02-10 20:03                 ` Robert A Duff
2012-02-13  3:28       ` BrianG
2012-02-10  8:47   ` Simon Wright
2012-02-09  3:38 ` Alex
     [not found]   ` <90a10801-440b-4a31-88d0-f0f7c17137f1@eb6g2000vbb.googlegroups.com>
2012-02-09 13:35     ` Alex
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox