How do I answer the followig using ARM Assembly Language with a Raspberry Pi? A
ID: 3747406 • Letter: H
Question
How do I answer the followig using ARM Assembly Language with a Raspberry Pi?
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.
As with all programs your program:
Checks user inputs for errors and print appropriate error messages.
Utensil Polypropylene Polystyrene Number made in one batch Fork 120 g 120 g 40 Spoon 100 g 60 g 40 Knife 140 g 160 g 60 Spork 90 g 110 g 50Explanation / 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.