Gives me the error on the line :while costumepmt <> 7777 AND revname <> 'qqqq' do, I really don't know what to do, please help, thanks in advance!
Program revelers_info;
uses wincrt;
var revnames, busybodies, summerbodies, readybodies, winnerbodies, goldenbodies :Array[1..7] of string;
costumepmt, busybodiescost, summerbodiescost, readybodiescost, winnerbodiescost, goldenbodiescost:Array[1..7] of real;
busybodiestot, summerbodiestot, readybodiestot, winnerbodiestot, goldenbodiestot, amount:real;
revname:string;
i, a, option, busybodiescnt, summerbodiescnt, readybodiescnt, winnerbodiescnt, goldenbodiescnt :integer;
Begin
a:= 1 ;
i:= 1;
busybodiescnt:=0;
summerbodiescnt:=0;
readybodiescnt:=0;
winnerbodiescnt:=0;
goldenbodiescnt:=0;
busybodiestot:=0;
summerbodiestot:=0;
readybodiestot:=0;
winnerbodiestot:=0;
goldenbodiestot:=0;
writeln('------------------------------------------------------------------------');
writeln('Welcome to THE MAIN EVENT Carnival Band Software!');
writeln;
Repeat
writeln('Please enter qqqq for name and 7777 for cost to terminate the process.');
writeln('Please choose one of the following options by entering the number of the option: ');
writeln('1. Add Information');
writeln('2. View Information');
writeln('3. Exit');
writeln;
readln(option);
If option = 1 then
Begin
writeln('Please enter a revelers name and then press the enter key.');
read(revname);
writeln('Please enter the amount paid by the Reveler for his or her costume.');
read(costumepmt[i]);
while costumepmt <> 7777 AND revname <> 'qqqq' do
Begin
revnames[i]:=revname;
If costumepmt = 144 then
Begin
busybodiescost[i]:= costumepmt[i];
busybodiestot:= busybodiestot+busybodiescost[i];
busybodies[i]:= revnames[i];
busybodiescnt:=busybodiescnt+1;
End;
If costumepmt = 204 then
Begin
summerbodiescost[i]:= costumepmt[i];
summerbodiestot:= summerbodiestot+summerbodiescost[i];
summerbodies[i]:= revnames[i];
summerbodiescnt:=summerbodiescnt+1;
End;
If costumepmt = 264 then
Begin
readybodiescost[i]:= costumepmt[i];
readybodiestot:= readybodiestot+readybodiescost[i];
readybodies[i]:= revnames[i];
readybodiescnt:=readybodiescnt+1;
End;
If costumepmt = 334 then
Begin
winnerbodiescost[i]:= costumepmt[i];
winnerbodiestot:= winnerbodiestot+winnerbodiescost[i];
winnerbodies[i]:= revnames[i];
winnerbodiescnt:=winnerbodiescnt+1;
End;
If costumepmt = 409 then
Begin
goldenbodiescost[i]:= costumepmt[i];
goldenbodiestot:= goldenbodiestot+goldenbodiescost[i];
goldenbodies[i]:= revnames[i];
goldenbodiescnt:=goldenbodiescnt+1;
End;
i:=i+1;
writeln('Please enter a Revelers name and then press the enter key.');
readln(revname);
writeln('Please enter the amount Paid by the Reveler mentioned.');
readln(costumepmt[i]);
End;
writeln;
End;
If option = 2 then
Begin
writeln('Busy Bodies Revelers names: ');
For a:= 1 to i do
Begin
writeln(busybodies[i]);
End;
writeln('The total cost calculated for the Busy Bodies Revelers is ' ,busybodiestot,'.');
writeln('The total number of Revelers in the Busy Bodies section is ' ,busybodiescnt,'.');
writeln('Summer Bodies Revelers names: ');
For a:= 1 to i do
Begin
writeln(summerbodies[i]);
End;
writeln('The total cost calculated for the Summer Bodies Revelers is ' ,summerbodiestot,'.');
writeln('The total number of Revelers in the Summer Bodies section is ' ,summerbodiescnt,'.');
writeln('Ready Bodies Revelers names: ');
For a:= 1 to i do
Begin
writeln(readybodies[i]);
End;
writeln('The total cost calculated for the Ready Bodies Revelers is ' ,readybodiestot,'.');
writeln('The total number of Revelers in the Ready Bodies section is ' ,readybodiescnt,'.');
writeln('Winner Bodies Revelers names: ');
For a:= 1 to i do
Begin
writeln(winnerbodies[i]);
End;
writeln('The total cost calculated for the Winner Bodies Revelers is ' ,winnerbodiestot,'.');
writeln('The total number of Revelers in the Winner Bodies section is ' ,winnerbodiescnt,'.');
writeln('Golden Bodies Revelers names: ');
For a:= 1 to i do
Begin
writeln(goldenbodies[i]);
End;
writeln('The total cost calculated for the Golden Bodies Revelers is ' ,goldenbodiestot,'.');
writeln('The total number of Revelers in the Golden Bodies section is ' ,goldenbodiescnt,'.');
End;
Until option = 3;
writeln('Thanks for stopping at THE MAIN EVENT Carnival Band Information boothe, now Get Ready For The ROOOOOAAAADDD!!!');
End.
- 2 Contributors
- forum1 Reply
- 161 Views
- 4 Years Discussion Span
- comment Latest Post by SalmiSoft
SalmiSoft 102
I am surprised that you get this error message. I would have expected a different one, perhaps "Incompatible Types". What compiler are you using?
costumepmt
is defined as an Array[1..7] of real
so it is not a single value, it is 7 values held in an array. So your code while costumepmt <> 7777
fails because you don't specify which of these 7 values to use. You probably mean to say: while costumepmt[i] <> 7777
This same problem appears several times in your code so you will need to make the same change in several places.
You may also have other problems with your while statement.
First, you have 2 conditions in your while condition so these will need brackets:
while (costumepmt[i] <> 7777) AND (revname <> 'qqqq') do
Second, your check (costumepmt[i] <> 7777)
is probably going to give you the wrong answer in some cases. This is because costumepmt[i] is a real value and you are comparing it with an integer. Real values that happen to be integers may not be stored as the exact integer, due to the way they are held in memory. So costumepmt[i] may be set to 7777 but stored as 7777.0000000304 or 7776.999999999997 or something, so you will think costumepmt[i] = 7777 but the computer will think differently. To get around this you could define costumepmt as an array of integers, or check if the difference between costumepmt[i] and 7777 is less than some small value, or round costumepmt[i] to the nearest integer and compare that to 7777. The first option is the best, if possible. If you opt for the rounding option you may run into some rounding oddities in Delphi.