Solved

output doesn't match number

Posted on 2000-04-17
1
180 Views
Last Modified: 2010-04-16
Here's my program:

var i: integer;

type string10 = string[10];


const
  ones: array[0..9] of string10 = ('', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine');
  tens: array[0..9] of string10 = ('','ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety');


function wordnumber (number: word) : string;
  begin
     wordnumber:= tens [number div 10] + '-' +ones [number div 10];
  end;

begin {main}
   for i:= 20 to 99 do
     writeln ('You write ',i, ' like this: ', wordnumber(i));
end.



This is the output it's giving me:

'You write 20 like this: twenty-two'

It gives me twenty-two from 20 to 29.

I'm having similar problems with the other numbers:

'You write 30 like this: thirty-three'   I get thirty-three from 30 to 39.

'You write 40 like this: forty-four'    I get forty-four from 40 to 49.

'You write 50 like this: fifty-five'  I get fifty-five from 50 to 59.

'You write 60 like this: sixty-six'  I get sixty-six from 60 to 69.

'You write 70 like this: seventy-seven'   I get seventy-seven from 70 to 79.

'You write 80 like this: eighty-eight'    I get eighty-eight from 80 to 89.

'You write 90 like this: ninety-nine'   I get ninety-nine from 90 to 99.


BTW... The program is supposed to let the user enter a number from 20 rto 99 and it outputs the number in equivalent number form.
0
Comment
Question by:kazooie21
1 Comment
 
LVL 12

Accepted Solution

by:
Hypo earned 10 total points
ID: 2724272
Hi,
There's one misstake in your code,
One of the "div"s should be a "mod"

Here's a modifyed version of your code

var i: integer;

type string10 = string[10];

const
  ones: array[0..9] of string10 = ('', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine');
  tens: array[0..9] of string10 = ('','ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety');


function wordnumber (number: word) : string;
  begin
     wordnumber:= tens [number div 10] + '-' +ones [number mod 10];
  end;

begin {main}
   for i:= 20 to 99 do
     writeln ('You write ',i, ' like this: ', wordnumber(i));
end.


0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
entry point in my program 14 496
USB Flash Drive Serial Numbers 9 4,022
.dat problems 39 208
Pass a string reference from one unit to another 8 119
Most MSPs worth their salt are already offering cybersecurity to their customers. But cybersecurity as a service is wide encompassing and can mean many things.  So where are MSPs falling in this spectrum?
ConnectWise and their customers need to ensure critical alerts automatically reach the right person at the right time. MSP superheros efficiently respond to these alerts key is providing automatic, intelligent alerting that generates a complete audi…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question