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.5 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,a2976536cf524fc2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-12-28 13:01:52 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!iad-peer.news.verio.net!news.verio.net!newsfeed.cwix.com!wn14feed!worldnet.att.net!bgtnsc04-news.ops.worldnet.att.net.POSTED!not-for-mail Reply-To: "James S. Rogers" From: "James S. Rogers" Newsgroups: comp.lang.ada References: Subject: Re: User defined TYPE error X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Message-ID: <3joP9.17723$p_6.1375396@bgtnsc04-news.ops.worldnet.att.net> Date: Sat, 28 Dec 2002 21:01:51 GMT NNTP-Posting-Host: 12.86.33.2 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 1041109311 12.86.33.2 (Sat, 28 Dec 2002 21:01:51 GMT) NNTP-Posting-Date: Sat, 28 Dec 2002 21:01:51 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:32369 Date: 2002-12-28T21:01:51+00:00 List-Id: "J.Matthews" wrote in message news:TrnP9.355$xE1.62211@stones... > Could someone possibly help. I get an error when I try to GET an amount. > I can make the program work without the user defined TYPE but I wanted > to restrict the input to valid monetary amounts i.e ���.pp format > > Any help appreciated > > > with ada.text_io,ada.integer_text_io,ada.float_text_io; > use ada.text_io,ada.integer_text_io,ada.float_text_io; > > procedure Money is > > Denomination : array (1..12) of integer := > (50,20,10,5,2,1,50,20,10,5,2,1); > type my_fixed is delta 0.01 range 0.00..1000.00; > Values : array (1..12) of my_fixed := > > (50.00,20.00,10.00,5.00,2.00,1.00,0.50,0.20,0.10,0.05,0.02,0.01); > Amount : my_fixed; > Count : array (1..12) of integer := (1..12 => 0); > Current_Value : integer := 0; > > begin > put("Enter Amount "); > get(Amount); Why are you using floating point I/O when you really need to instantiate Ada.Text_IO.Decimal_IO for your fixed point type? Your error is that you are trying to input a fixed point type using a floating point I/O package. > Amount := Amount+0.001; --ADA float number fix > Current_value := 1; > while Amount >= 0.01 loop > while Amount > values(Current_Value) loop > Amount := Amount - values(Current_Value); > Count(Current_Value) := Count(Current_Value)+1; > end loop; > Current_Value:=Current_Value+1; > End Loop; > new_line; > > for x in 1..4 loop > if Count(x) >= 1 then > put(Count(x)); > put(" X "); > put(character'val (156)); > put(denomination(x),width=>1); > if count(x) >=2 then > put_line(" NOTES"); > else > put_line(" NOTE"); > end if; > end if; > end loop; > > for x in 5..6 loop > if Count(x) >= 1 then > put(Count(x)); > put(" X "); > put(character'val (156)); > put(denomination(x),width=>1); > if count(x) >=2 then > put_line(" COINS"); > else > put_line(" COIN"); > end if; > end if; > end loop; > > for x in 7..12 loop > if Count(x) >= 1 then > put(Count(x)); > put(" X "); > put(denomination(x),width=>1); > if count(x) >=2 then > put_line("p COINS"); > else > put_line("p COIN"); > end if; > end if; > end loop; > > end money; Jim Rogers