Maximum value in results - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# Maximum value in results

Posts: 2Member
Hi, I'm looking for with some pascal code. I have to make a program which allows you to input a name and an amount four times. Then it is supposed to output the name, three percentages of the amount and the maximum of one of the percentage out of the four outputted results. can any one help? This is what I have so far:

program grocery;
uses wincrt;
var
Name:Array[1..4] of String;
Amount:Array[1..4] of longint;
i:Integer;
B_sector,L_sector,V_sector:double;
Begin
For i:=1 to 4 do
Begin;
Writeln('Enter Organisation Name');
Readln(Name[i]);
Writeln('Enter the amount');
Readln(Amount[i]);
B_sector:=(Amount[i])*40/100;
V_sector:=(Amount[i])*25/100 ;
L_sector:=(Amount[i])*35/100 ;
Writeln(Name[i]);
Writeln(B_sector:2:1);
Writeln(V_sector:2:1);
Writeln(L_sector:2:1);

End;

End.

## Comments

• Posts: 24Member
not sure about the maximum you want but have a look at this:

program grocery;
uses wincrt;
var
Name:Array[1..4] of String;
Amount:Array[1..4] of longint;
i,j:Integer;
B_sector,L_sector,V_sector:double;

sector:array[1..4,1..3] of double;
max: double;
begin

for i:=1 to 4 do
begin;
Writeln('Enter Organisation Name');
Readln(Name[i]);

Writeln('Enter the amount');
Readln(Amount[i]);

{B_sector:=(Amount[i])*40/100;
V_sector:=(Amount[i])*25/100 ;
L_sector:=(Amount[i])*35/100 ;}

sector[i,1]:=(Amount[i])*40/100;
sector[i,2]:=(Amount[i])*25/100;
sector[i,3]:=(Amount[i])*35/100;

Writeln(Name[i]);
Write(sector[i,1]5,' ');
Write(sector[i,2]5,' ');
Writeln(sector[i,3]5);
end;

max:=sector[1,1];
for i:=1 to 4 do
for j:=1 to 3 do if sector[i,j]>=max then max:=sector[i,j];

writeln(max5);

end.
• Posts: 24Member
or better this:

program grocery;
uses wincrt;
var
Name:Array[1..3] of String;
Amount:Array[1..3] of longint;
i,j:Integer;
B_sector,L_sector,V_sector:double;

sector:array[1..3,1..3] of double;
max: double;
begin

for i:=1 to 3 do
begin
Writeln('Enter Organisation Name');
Readln(Name[i]);

Writeln('Enter the amount');
Readln(Amount[i]);
end;

clrscr;

for i:=1 to 3 do
begin

{B_sector:=(Amount[i])*40/100;
V_sector:=(Amount[i])*25/100 ;
L_sector:=(Amount[i])*35/100 ;}

sector[i,1]:=(Amount[i])*40/100;
sector[i,2]:=(Amount[i])*25/100;
sector[i,3]:=(Amount[i])*35/100;

Writeln(Name[i],':');
Write(sector[i,1]5,' ');
Write(sector[i,2]5,' ');
Writeln(sector[i,3]5);
writeln;
end;

max:=sector[1,1];
for i:=1 to 3 do
for j:=1 to 3 do if sector[i,j]>=max then max:=sector[i,j];

writeln;
write('the max percentage is: ',max5);

end.
• Posts: 1Member
The site wont let me use my profile, so i had to make this new one. But thanks anyway
Sign In or Register to comment.