The "SUPER GOODS " Pvt. Ltd. manufactures spices for the export market. In the factory, there are two machines called A and B. The following table shows a sample production of each machine in seven days. Day1 Day2 Day3 Day4 Day5 Day6 Day 7 Production of Machine A 160 180 150 110 190 140 165 Production of Machine B 180 100 115 170 155 165 195
Write a program in pseudocode to
• Declare a two-dimensional array to store these data and get user input to load the array. • Find the total production of machine A in the entire week. • Display the highest production and name of the machine that produced it.
Start
Declare array dataAB[][7]={{160,180,150,110,190,140,165},{180,100,115,170,155,165,195}}
Set totalProduction to 0
for i=0 to 7
totalProduction=totalProduction+dataAB[0][i]
end for
Display "The total production of machine A in the entire week: "+totalProduction+"\n"
Set highestProduction to dataAB[0][0]
Set indexI to 0
Set indexJ to 0
for i=0 to 2
for j=0 to 7
if highestProduction<dataAB[i][j] then
Set highestProduction to dataAB[i][j]
Set indexI to i
Set indexJ to j
end if
end for
end for
Set nameMachine to "A"
if indexI=1 then
Set nameMachine to "B"
end if
Display "The highest production is: "+dataAB[indexI][indexJ]+" the name of the machine that produced it is: "+nameMachine
Stop
Comments
Leave a comment