Write a solution for a predicate that translates numbers in
English in ADA, for example: Number: 1000 is one
thousand Number:1103 is one thousand one hundred three The program
should enter into a loop for reading a number and translating it
until we type the word ”halt.”, instead of a number.
**The range can be up to 9999***
toenglish.adb
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO;
procedure toenglish (N : Integer) is
num : Integer:=N;
num1 : Integer:=N;
l : Integer:=0;
digit1 : Integer;
digit2 : Integer;
digit3 : Integer;
digit4 : Integer;
type OneArray is array(1..19) of Unbounded_String;
one: OneArray;
type TwoArray is array(1..9) of Unbounded_String;
two: TwoArray;
type ThreeArray is array(1..9) of Unbounded_String;
three: ThreeArray;
type FourArray is array(1..9) of Unbounded_String;
four: FourArray;
begin
one(1):=To_Unbounded_String("one");
one(2):=To_Unbounded_String("two");
one(3):=To_Unbounded_String("three");
one(4):=To_Unbounded_String("four");
one(5):=To_Unbounded_String("five");
one(6):=To_Unbounded_String("six");
one(7):=To_Unbounded_String("seven");
one(8):=To_Unbounded_String("eight");
one(9):=To_Unbounded_String("nine");
one(10):=To_Unbounded_String("ten");
one(11):=To_Unbounded_String("eleven");
one(12):=To_Unbounded_String("twelve");
one(13):=To_Unbounded_String("thirteen");
one(14):=To_Unbounded_String("fourteen");
one(15):=To_Unbounded_String("fifteen");
one(16):=To_Unbounded_String("sixteen");
one(17):=To_Unbounded_String("seventeen");
one(18):=To_Unbounded_String("eighteen");
one(19):=To_Unbounded_String("nineteen");
two(1):=To_Unbounded_String("ten");
two(2):=To_Unbounded_String("twenty");
two(3):=To_Unbounded_String("thirty");
two(4):=To_Unbounded_String("fourty");
two(5):=To_Unbounded_String("fifty");
two(6):=To_Unbounded_String("sixty");
two(7):=To_Unbounded_String("seventy");
two(8):=To_Unbounded_String("eighty");
two(9):=To_Unbounded_String("ninety");
three(1):=To_Unbounded_String("one hundred");
three(2):=To_Unbounded_String("two hundred");
three(3):=To_Unbounded_String("three hundred");
three(4):=To_Unbounded_String("four hundred");
three(5):=To_Unbounded_String("five hundred");
three(6):=To_Unbounded_String("six hundred");
three(7):=To_Unbounded_String("seven hundred");
three(8):=To_Unbounded_String("eight hundred");
three(9):=To_Unbounded_String("nine hundred");
four(1):=To_Unbounded_String("one thousand");
four(2):=To_Unbounded_String("two thousand");
four(3):=To_Unbounded_String("three thousand");
four(4):=To_Unbounded_String("four thousand");
four(5):=To_Unbounded_String("five thousand");
four(6):=To_Unbounded_String("six thousand");
four(7):=To_Unbounded_String("sevent thousand");
four(8):=To_Unbounded_String("eight thousand");
four(9):=To_Unbounded_String("nine thousand");
while num > 0 loop
l:=l+1;
num := num / 10;
end loop;
digit1:=(num1 rem 10);
num1:=num1/10;
digit2:=(num1 rem 10);
num1:=num1/10;
digit3:=(num1 rem 10);
num1:=num1/10;
digit4:=(num1 rem 10);
if l=1 then
Put(one(digit1));
elsif l=2 then
if N>=11 and N<=19 then
Put(one(N));
elsif(digit1=0) then
Put(two(digit2));
else
Put(two(digit2)); Put(" "); Put(one(digit1));
end if;
elsif l=3 then
if digit2=0 and digit1=0 then
Put(three(digit3));
elsif digit2=0 then
Put(three(digit3)); Put(" "); Put(one(digit1));
elsif digit1=0 then
Put(three(digit3)); Put(" "); Put(two(digit2));
elsif digit2 = 1 and digit1 /= 0 then
Put(three(digit3)); Put(" "); Put(one(10+digit1));
else
Put(three(digit3)); Put(" "); Put(two(digit2)); Put(" "); Put(one(digit1));
end if;
elsif l=4 then
if digit3=0 and digit2=0 and digit1=0 then
Put(four(digit4));
elsif digit2=0 and digit1=0 then
Put(four(digit4)); Put(" "); Put(three(digit3));
elsif digit3=0 and digit1=0 then
Put(four(digit4)); Put(" "); Put(two(digit2));
elsif digit3=0 and digit2=0 then
Put(four(digit4)); Put(" "); Put(one(digit1));
elsif digit3 = 0 and digit2 = 1 and digit1 /= 0 then
Put(four(digit4)); Put(" "); Put(one(10+digit1));
elsif digit3 /= 0 and digit2 = 1 and digit1 /= 0 then
Put(four(digit4)); Put(" "); Put(three(digit3)); Put(" "); Put(one(10+digit1));
elsif digit3=0 then
Put(four(digit4)); Put(" "); Put(two(digit2)); Put(" "); Put(one(digit1));
elsif digit2=0 then
Put(four(digit4)); Put(" "); Put(three(digit3)); Put(" "); Put(one(digit1));
elsif digit1=0 then
Put(four(digit4)); Put(" "); Put(three(digit3)); Put(" "); Put(two(digit2));
else
Put(four(digit4)); Put(" "); Put(three(digit3)); Put(" "); Put(two(digit2)); Put(" "); Put(one(digit1));
end if;
else
Put_Line("Number should be betweeen 1 - 9999");
end if;
end toenglish;
main.adb
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with toenglish;
procedure main is
A : Integer;
S : String(1 .. 10) := (others => ' ');
begin
while True loop
Put ("Enter a number between 1-9999 : ");
Get (A);
toenglish(A);
Put_Line(" ");
end loop;
end main;
Note : Save both files on same location, first compile toenglish.adb and then compile and run main.adb. I didn't include code for exit loop when "halt" is entered, loop automatically exits when any string input is given.
Write a solution for a predicate that translates numbers in English in ADA, for example: Number:...
Using C++ Design a class called Numbers that can be used to translate integers in the range 0 to 9999 into an English description of the number. The class should have a single integer member variable: int number; and a static array of string objects that specify how to translate the number into the desired format. For example, you might use static string arrays such as: string lessThan20[20] = {"zero", "one", ..., "eighteen", "nineteen"}; string hundred = "hundred"; string thousand...
i need help making this C++ code. Lab #2 Assignments: Numbers Class that translate whole dollar amounts in the range 0 through 9999 into an English description of the number. Numbers Class Design a class numbers that can be used to translate whole dollar amounts in the range 0 through 9999 into an English description of the number. For example, the number 713 would be translated into the string seven hundred thirteen, and 8203 would be translated into eight thousand...
Write a computer program that prompts the user for one number, n for the number of items in the array to sort, and create and sort 1000 different arrays of this size timing the run to get an average time to sort an array of this size. Then do the following: Initiate a variable running_time to 0 Create a for loop that iterates 1000 times. In the body of the loop, Create an array of n random integers (Make sure...
Assignment Develop a program to analyze one or more numbers entered by a user. The user may enter one or more numbers for analysis. Input should be limited to numbers from 1 through 1000. Determine if a number is a prime number or not. A prime number is one whose only exact divisors are 1 and the number itself (such as 2, 3, 5, 7, etc.). For non-prime numbers, output a list of all divisors of the number. Format your...
About Classes and OOP in C++ Part 1 Task 1: Create a class called Person, which has private data members for name, age, gender, and height. You MUST use this pointer when any of the member functions are using the member variables. Implement a constructor that initializes the strings with an empty string, characters with a null character and the numbers with zero. Create getters and setters for each member variable. Ensure that you identify correctly which member functions should...
Write a program that writes a series of random numbers to a file. Each random number should be in the range of 1 through 500 inclusive. 1.Use a file called randoms.txt as a input file and output file a. If you go to open the file and its not there then ask the user to create the file and then quit 2. Ask the user to specify how many random numbers the file will hold. a.Make sure that the...
Write a MARIE program to calculate some basic statistics on a list of positive numbers. The program will ask users to input the numbers one by one. Assume that all numbers will be in the range 1 to 1000. To terminate the data entry, user will input any negative number. Once the data entry is complete, the program will show four statistics about the list of numbers: (1) Count (2) Minimum value (3) Sum of numbers (4) "Mean/Average" calculation. As...
Requirement Write pseudocode and translate it to ONE C-program for each the following problems. In your pseudocode and C-program, use only what you have learned in this class so far. (Menu) Design a menu for question 2 and 3. So far, you use one program to solve all lab questions. But some of you may feel awkward when you want to demo/test only one lab question. To overcome that, your program should show a menu so that the users of...
Program Info: Write a program that accepts a year written as a four-digit Arabic (ordinary) numeral and outputs the year written in Roman numerals. Important Roman numerals are V for 5, X for 10, L for 50, C for 100, D for 500, and M for 1,000. Recall that some numbers are formed by using a kind of subtraction of one Roman “digit”; for example, IV is 4 produced as V minus I, XL is 40, CM is 900, and...
In Java Problem Description/Purpose: Write a program that will compute and display the final score of two teams in a baseball game. The number of innings in a baseball game is 9. Your program should read the name of the teams. While the user does not enter the word done for the first team name, your program should read the second team name and then read the number of runs for each Inning for each team, calculate the...