This program is in ARM assembly language using the stacks. The stack pointer is
ID: 3744530 • Letter: T
Question
This program is in ARM assembly language using the stacks. The stack pointer is r13, and the frame pointer is r11. Thanks!
A plastic company has a machine that makes plastic spoons, forks, knives and sporks. There are two separate vats of polypropylene and polystyrene that make the plastic that is injected into the molds. The amount of each used depends on the utensil being made and is identified in the table below. The table also identifies the number of that utensil type made in one batch. The program is to prompt the user for the utensil to make and run until the user quits or runs out of the plastic to make a minimum batch. After each batch print the total number of each type of utensil made and the amount of plastic left in the vats. The polypropylene vat starts out with 50 kilograms and the Polystyrene vat starts out with 75 kilograms Utensil Polypropylene Polystyrene Number made in Fork120 g Spoon 100 g Knife 140 g Spork 90g one batch 120 g 60 g 60 g 110 g 40 40 60 50 As with all programs your program: 1. Checks user inputs for errors and print appropriate error messages 2. Has all outputs clearly labeled. 3. Contains generous code documentation.Explanation / Answer
/******************************************************************************
*******************************************************************************/
#include <iostream>
using namespace std;
float ploy_p = 0, poly_s = 0;
int choice;
//************************************************************************************
void cal(int div_1,int div_2,int num_)
{
int f1 = (int)ploy_p/div_1;
int f2 = (int)poly_s/div_2;
if(f1> 1 && f2 >1)
{
if(f1==f2)
{
cout<<"Number of Fork =>>"<<f1*num_;
}
elseif(f1>f2)
{
f = f1-f2;
f1 = f1 -f;
cout<<"Number of Fork =>>"<<f1*num_;
cout<<"Amount of plastic remaining =>>"<<f;
}
else
{
f = f2-f1;
f2 = f2 -f;
cout<<"Number of Fork =>>"<<f2*num_;
cout<<"Amount of plastic remaining =>>"<<f;
}
}
else
{
cout<<"Minimum item is not made by system";
}
}
void all()
{
ploy_p1 = ploy_p/4;
poly_s1 = poly_s/4;
cal(120,120,40);
cal(100,60,40);
cal(140,160,60);
cal(90,110,50);
}
int getInt(){
int x;
while (true){
//cout << "Enter an int." << endl;
cin.clear();
while(cin.get() != ' ');
cin >> x;
if (!cin.fail()){
return x;
}
}
}
//**********************************************************************************
int main()
{
cout<<"Enter amount of Polypropylene(grms) : ";
ploy_p = getInt() ;
//cout<<endl;
cout<<"Enter amount of Polystyrene(grms) : ";
poly_s = getInt() ;
cout<<"Polypropylene(grms) : "<<ploy_p;
cout<<"Polystyrene(grms) : "<<poly_s<<endl;
cout<<"***********************************************"<<endl;
while(1)
{
cout << endl
<< " 1 - Make Fork. "
<< " 2 - Make Spoon. "
<< " 3 - Make Knife. "
<< " 4 - Make Spork. "
<< " 5 - Make ALL. "
<< " 6 - Exit. "
<< " Enter your choice and press return: ";
cin >> choice;
switch (choice)
{
case 1:
cal(120,120,40);
break;
case 2:
cal(100,60,40);
break;
case 3:
cal(140,160,60);
break;
case 4:
cal(90,110,50);
break;
case 5:
// all();
break;
case 6:
exit(0);
break;
default:
cout << "Not a Valid Choice. "
<< "Choose again. ";
break;
}
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.