This is the first part of the programming that I'm working on.
Ignore the excessive comments. I placed all those comments because i need to break it into modules once the rest of the program is developed.
Program Expenditure;
uses
crt;
Var
Terminate : Integer; {The 'Terminate' variable, tests if data entry should be terminated}
CustomerID: Integer; {The 'CustomerID' variable is used to index and store data in multiple arrays}
CustomerNames : array[1..10] of string; {Stores the names of customers}
ExpenditureAmt: array[1..10] of Real;{Stores the Expenditure of respective customers}
CheckGreatestAmt : Real; {Records the largest expenditure amount for the second module}
ExpenditureLoop: Integer; {This will control the flow of the loop in the second module}
Begin
{Program must be split into modules, this will act as the first module. Looping the Data Entry Process}
Terminate := 1;
CustomerID:= 0;
while Terminate <> 0 do
begin
CustomerID := CustomerID + 1;
Writeln ('Input the First And Last Name of the Customer: ');
Readln (CustomerNames[CustomerID]);
Writeln ('Input the Expenditure of ' , CustomerNames[CustomerID] , ':');
Readln (ExpenditureAmt[CustomerID]);
Writeln ('To Terminate Data Entry Press 0 or Press Any Other Number to Continue: ');
Readln (Terminate);
ClrScr;
End;
{The End of the Data Entry Phase of the Program Completed}
{Second Module, This will find the customer with the greatest expenditure and also the corresponding name}
CheckGreatestAmt := 0;
for ExpenditureLoop := 1 to CustomerID do
Begin
if ExpenditureAmt[ExpenditureLoop] > CheckGreatestAmt then
CheckGreatestAmt := ExpenditureAmt[ExpenditureLoop];
End;
Writeln ('The Largest Expenditure Made was ' , CheckGreatestAmt:2);
Writeln ('This was made by 'CustomerNames[ExpenditureLoop]);
{Second Module Ends Here.}
Readln();
End.
The program accepts the following user input - name of customer and the respective expenditure. Then it will find the largest expenditure and then find the corresponding name of the customer. This is where the problem occurs. The largrest expenditure is found by running a For Loop in the array "ExpenditureAmt". When the largest is found i need a way to find the Customer which spent that Amount. My other problem is the output format .
How can i get rid of output like this 1.0E+001?
Thanks in advance for your help!


Sign In
Create Account

Back to top









