Can you write pseudocode for this program? global choice global x1 x2 x3 x4 x5; item1 = ["Swager Gauge" 9000 15]; item2 = ["ATS Angled Air Drill" 20000 20]; item3 = ["Battery Terminal Socket" 10000 5]; item4 = ["Telescoping Flashlight" 50000 10]; item5 = ["Spray Wand Engine Cleaner" 4000 20]; %item = [item1; item2; item3; item4; item5] x5=0; x4=x5; x3=x4; x2=x3; x1=x2; main(); while choice if choice ==1 clc list(); product = input('Please Select Product from the List? ' ); if product ==1 quantity1 = input('Enter the quantity of the Product '); while((str2num(item1(3)))<=quantity1) fprintf('\t\t !!Quantity not available. Enter Again!!\n'); quantity1 = input('Enter the quantity of the Product ') end x1 = x1+ quantity1 list(); elseif product ==2 quantity2 = input('Enter the quantity of the Product '); while((str2num(item2(3)))<=quantity2) fprintf('\t\t !!Quantity not available. Enter Again!!\n'); quantity2 = input('Enter the quantity of the Product ') end x2 = x2+quantity2 list(); elseif product ==3 quantity3 = input('Enter the quantity of the Product '); while((str2num(item3(3)))<=quantity3) fprintf('\t\t !!Quantity not available. Enter Again!!\n'); quantity3 = input('Enter the quantity of the Product ') end x3 = x3 + quantity3 list(); elseif product ==4 quantity4 = input('Enter the quantity of the Product '); while((str2num(item4(3)))<=quantity4) fprintf('\t\t !!Quantity not available. Enter Again!!\n'); quantity4 = input('Enter the quantity of the Product ') end x4 = x4 + quantity4 list(); elseif product ==5 quantity5 = input('Enter the quantity of the Product '); while((str2num(item5(3)))<=quantity5) fprintf('\t\t !!Quantity not available. Enter Again!!\n'); quantity5 = input('Enter the quantity of the Product ') end x5 = x5 +quantity5 list(); elseif product == 0 main(); end elseif choice ==2 clc fprintf('Products in your cart\n') if x1~=0 fprintf('%s \t\t\t\t\tQuantity=%d \t\t\tUnit Price=%s \n',item1(1),x1,item1(2)) end if x2~=0 fprintf('%s \t\t\tQuantity=%d \t\t\tUnit Price=%s \n',item2(1),x2,item2(2)) end if x3~=0 fprintf('%s \t\tQuantity=%d \t\t\tUnit Price=%s \n',item3(1),x3,item3(2)) end if x4~=0 fprintf('%s \t\t\tQuantity=%d \t\t\tUnit Price=%s \n',item4(1),x4,item4(2)) end if x5~=0 fprintf('%s \t\tQuantity=%d \t\t\tUnit Price=%s \n',item5(1),x5,item5(2)) end cart = input('Do you Want to Checkout (Y/N): ','s'); if cart == 'y' name = input('Please Enter Your Name: ','s'); address = input('Please Enter Your Address: ','s'); fprintf('\n'); fprintf('The total amount you need to pay is %d AED.',x1*str2num(item1(2))+x2*str2num(item2(2))+x3*str2num(item3(2))+x4*str2num(item4(2))+x5*str2num(item5(2))) fprintf('\n'); fprintf(' Products \t\t\t\t\t Quantity \t Price \n\n'); if x1~=0 fprintf('%s \t\t\t\t\t%d \t\t\t\t %s \n',item1(1),x1,item1(2)) end if x2~=0 fprintf('%s \t\t\t%d \t\t\t\t %s \n',item2(1),x2,item2(2)) end if x3~=0 fprintf('%s \t\t%d \t\t\t\t %s \n',item3(1),x3,item3(2)) end if x4~=0 fprintf('%s \t\t\t%d \t\t\t\t %s \n',item4(1),x4,item4(2)) end if x5~=0 fprintf('%s \t\t%d \t\t\t\t %s \n',item5(1),x5,item5(2)) end fprintf('\n') fprintf('Total price \t\t\t\t %d .',x1*str2num(item1(2))+x2*str2num(item2(2))+x3*str2num(item3(2))+x4*str2num(item4(2))+x5*str2num(item5(2))) fprintf('\n') item1 = ["Swager Gauge" 9000 15-x1]; item2 = ["ATS Angled Air Drill" 20000 20-x2]; item3 = ["Battery Terminal Socket" 10000 5-x3]; item4 = ["Telescoping Flashlight" 50000 10-x4]; item5 = ["Spray Wand Engine Cleaner" 4000 20-x5]; back = input('Do you Want to go back to main menu (Y/N): ','s'); if back == 'y' main(); end else main(); end elseif choice == 3 disp('exit') break end end %% function main() clc fprintf('\t \t Welcome to the AirCraft Supplies Shop! \n \n') fprintf('Please Select Any Option to Continue:\n') fprintf('1. List of Available AirCraft Supplies \n2. Checkout Cart \n3. Exit \n \n') global choice ; choice = input('select among choices: '); end %% function list() global x1 x2 x3 x4 x5; item1 = ["Swager Gauge" 9000 15-x1]; item2 = ["ATS Angled Air Drill" 20000 20-x2]; item3 = ["Battery Terminal Socket" 10000 5-x3]; item4 = ["Telescoping Flashlight" 50000 10-x4]; item5 = ["Spray Wand Engine Cleaner" 4000 20-x5]; fprintf('\t \tDisplaying available Supplies in Store \n \n') fprintf(' Supplies \t\t\t\t\t Price(AED) \t Quantity\n\n'); fprintf('%s \t\t\t\t\t%s \t\t\t%s \n',item1(1),item1(2),item1(3)) fprintf('%s \t\t\t%s \t\t\t%s \n',item2(1),item2(2),item2(3)) fprintf('%s \t\t%s \t\t\t%s \n',item3(1),item3(2),item3(3)) fprintf('%s \t\t\t%s \t\t\t%s \n',item4(1),item4(2),item4(3)) fprintf('%s \t\t%s \t\t\t%s \n \n',item5(1),item5(2),item5(3)) fprintf('Please Select the Product You wish to buy from the list\n \t 1. Swager Gauge \n\t 2. ATS Angled Air Drill \n\t 3. Battery Terminal Socket\n\t 4. Telescoping Flashlight\n\t 5. Spray Wand Engine Cleaner\n\t 0. Back to main Menu\n') end
Can you write pseudocode for this program?
global choice
global x1 x2 x3 x4 x5;
item1 = ["Swager Gauge" 9000 15];
item2 = ["ATS Angled Air Drill" 20000 20];
item3 = ["Battery Terminal Socket" 10000 5];
item4 = ["Telescoping Flashlight" 50000 10];
item5 = ["Spray Wand Engine Cleaner" 4000 20];
%item = [item1; item2; item3; item4; item5]
x5=0; x4=x5; x3=x4; x2=x3; x1=x2;
main();
while choice
if choice ==1
clc
list();
product = input('Please Select Product from the List? ' );
if product ==1
quantity1 = input('Enter the quantity of the Product ');
while((str2num(item1(3)))<=quantity1)
fprintf('\t\t !!Quantity not available. Enter Again!!\n');
quantity1 = input('Enter the quantity of the Product ')
end
x1 = x1+ quantity1
list();
elseif product ==2
quantity2 = input('Enter the quantity of the Product ');
while((str2num(item2(3)))<=quantity2)
fprintf('\t\t !!Quantity not available. Enter Again!!\n');
quantity2 = input('Enter the quantity of the Product ')
end
x2 = x2+quantity2
list();
elseif product ==3
quantity3 = input('Enter the quantity of the Product ');
while((str2num(item3(3)))<=quantity3)
fprintf('\t\t !!Quantity not available. Enter Again!!\n');
quantity3 = input('Enter the quantity of the Product ')
end
x3 = x3 + quantity3
list();
elseif product ==4
quantity4 = input('Enter the quantity of the Product ');
while((str2num(item4(3)))<=quantity4)
fprintf('\t\t !!Quantity not available. Enter Again!!\n');
quantity4 = input('Enter the quantity of the Product ')
end
x4 = x4 + quantity4
list();
elseif product ==5
quantity5 = input('Enter the quantity of the Product ');
while((str2num(item5(3)))<=quantity5)
fprintf('\t\t !!Quantity not available. Enter Again!!\n');
quantity5 = input('Enter the quantity of the Product ')
end
x5 = x5 +quantity5
list();
elseif product == 0
main();
end
elseif choice ==2
clc
fprintf('Products in your cart\n')
if x1~=0
fprintf('%s \t\t\t\t\tQuantity=%d \t\t\tUnit Price=%s \n',item1(1),x1,item1(2))
end
if x2~=0
fprintf('%s \t\t\tQuantity=%d \t\t\tUnit Price=%s \n',item2(1),x2,item2(2))
end
if x3~=0
fprintf('%s \t\tQuantity=%d \t\t\tUnit Price=%s \n',item3(1),x3,item3(2))
end
if x4~=0
fprintf('%s \t\t\tQuantity=%d \t\t\tUnit Price=%s \n',item4(1),x4,item4(2))
end
if x5~=0
fprintf('%s \t\tQuantity=%d \t\t\tUnit Price=%s \n',item5(1),x5,item5(2))
end
cart = input('Do you Want to Checkout (Y/N): ','s');
if cart == 'y'
name = input('Please Enter Your Name: ','s');
address = input('Please Enter Your Address: ','s');
fprintf('\n');
fprintf('The total amount you need to pay is %d AED.',x1*str2num(item1(2))+x2*str2num(item2(2))+x3*str2num(item3(2))+x4*str2num(item4(2))+x5*str2num(item5(2)))
fprintf('\n');
fprintf(' Products \t\t\t\t\t Quantity \t Price \n\n');
if x1~=0
fprintf('%s \t\t\t\t\t%d \t\t\t\t %s \n',item1(1),x1,item1(2))
end
if x2~=0
fprintf('%s \t\t\t%d \t\t\t\t %s \n',item2(1),x2,item2(2))
end
if x3~=0
fprintf('%s \t\t%d \t\t\t\t %s \n',item3(1),x3,item3(2))
end
if x4~=0
fprintf('%s \t\t\t%d \t\t\t\t %s \n',item4(1),x4,item4(2))
end
if x5~=0
fprintf('%s \t\t%d \t\t\t\t %s \n',item5(1),x5,item5(2))
end
fprintf('\n')
fprintf('Total price \t\t\t\t %d .',x1*str2num(item1(2))+x2*str2num(item2(2))+x3*str2num(item3(2))+x4*str2num(item4(2))+x5*str2num(item5(2)))
fprintf('\n')
item1 = ["Swager Gauge" 9000 15-x1];
item2 = ["ATS Angled Air Drill" 20000 20-x2];
item3 = ["Battery Terminal Socket" 10000 5-x3];
item4 = ["Telescoping Flashlight" 50000 10-x4];
item5 = ["Spray Wand Engine Cleaner" 4000 20-x5];
back = input('Do you Want to go back to main menu (Y/N): ','s');
if back == 'y'
main();
end
else
main();
end
elseif choice == 3
disp('exit')
break
end
end
%%
function main()
clc
fprintf('\t \t Welcome to the AirCraft Supplies Shop! \n \n')
fprintf('Please Select Any Option to Continue:\n')
fprintf('1. List of Available AirCraft Supplies \n2. Checkout Cart \n3. Exit \n \n')
global choice ;
choice = input('select among choices: ');
end
%%
function list()
global x1 x2 x3 x4 x5;
item1 = ["Swager Gauge" 9000 15-x1];
item2 = ["ATS Angled Air Drill" 20000 20-x2];
item3 = ["Battery Terminal Socket" 10000 5-x3];
item4 = ["Telescoping Flashlight" 50000 10-x4];
item5 = ["Spray Wand Engine Cleaner" 4000 20-x5];
fprintf('\t \tDisplaying available Supplies in Store \n \n')
fprintf(' Supplies \t\t\t\t\t Price(AED) \t Quantity\n\n');
fprintf('%s \t\t\t\t\t%s \t\t\t%s \n',item1(1),item1(2),item1(3))
fprintf('%s \t\t\t%s \t\t\t%s \n',item2(1),item2(2),item2(3))
fprintf('%s \t\t%s \t\t\t%s \n',item3(1),item3(2),item3(3))
fprintf('%s \t\t\t%s \t\t\t%s \n',item4(1),item4(2),item4(3))
fprintf('%s \t\t%s \t\t\t%s \n \n',item5(1),item5(2),item5(3))
fprintf('Please Select the Product You wish to buy from the list\n \t 1. Swager Gauge \n\t 2. ATS Angled Air Drill \n\t 3. Battery Terminal Socket\n\t 4. Telescoping Flashlight\n\t 5. Spray Wand Engine Cleaner\n\t 0. Back to main Menu\n')
end
Step by step
Solved in 2 steps