Algorithm and Data Structure Assignment, MUM, Malaysia Write a menu-based program to create a list of records (at least 3 data) using the queue concept
University | Monash University Malaysia (MUM) |
Subject | Algorithm and Data Structure |
Question
Write a menu-based program to create a list of records (at least 3 data) using the queue concept. Your program should be able to perform the following queue operation.
1. Enqueue
2. Dequeue
3. Queue rear
4. Queue front
4. View
5. Exit
This program is designed using a Structure which is a computer and its components. It has the ability to receive input from a user. It starts by asking the user their name. After it has been input, the screen clears, then it proceeds to ask the user if they need to fill in 5 orders for the computer with a Yes or No option.
If the user says no, the screen clears and the program will terminate. If the user says yes, the screen clears and the program proceeds to ask the user to input details such as the mainboard name, processor cores, ram size, hard disk size, and power wattage for 5 pcs. The final output then displays in a table all the components for all the PCs. If the input is invalid, the user will be asked to re-enter a valid value.
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
struct computer
{
int ramSize, hardDrive, processorCore, powerSupply;
string mainboard;
} pc1, pc2, pc3, pc4, pc5;
string name, input;
int main()
{
cout << ” ——————– \n”;
cout << “| PC Components |\n”;
cout << ” ——————– \n\n”;
cout << “What is your name? \n”;
getline(cin >> ws, name);
cout << endl;
system (“clear”);
cout << ” ——————– \n”;
cout << “| PC Components |\n”;
cout << ” ——————– \n\n”;
cout << “Welcome ” << name << “! \n\n”;
cout << “We were told you have 5 PC orders to fill.” “\nIs this correct? \n\n”;
cout << “Press ‘Y’ for YES or ‘N’ for NO \n”;
cin >> input;
if (input == “y” || input == “Y”)
{
system (“clear”);
cout << “\nPlease Enter the components according to the PC’s. \n\n”;cout << “Enter
Components for PC1” << endl << endl;
cout << “Mainboard Brand: “;
getline (cin >> ws, pc1.mainboard);
cout << “Number of Processor Cores: “;
cin >> pc1.processorCore;
while(1)
{
if(cin.fail())
{
cin.clear();
cin.ignore();
cout<<“You have entered an invalid input!”<<endl;
cout << “Number of Processor Cores: “;
cin >> pc1.processorCore;
}
if(!cin.fail())
break;
}
cout << “Ram Size in Gb: “;
cin >> pc1.ramSize;
while(2)
{
if(cin.fail())
{
cin.clear();
cin.ignore();
cout<<“You have entered an invalid input!”<<endl;
cout << “Ram Size in Gb: “;
cin >> pc1.ramSize;
}
if(!cin.fail())
break;
}
cout << “Hard Drive Storage in Gb: “;
cin >> pc1.hardDrive;
while(3)
{
if(cin.fail())
{
cin.clear();
cin.ignore();
cout<<“You have entered an invalid input!”<<endl;
cout << “Hard Drive Storage in Gb: “;
cin >> pc1.hardDrive;
}
if(!cin.fail())
break; }
cout << “Power Supply Watts: “;
cin >> pc1.powerSupply;
while(4)
{
if(cin.fail())
{
cin.clear();
cin.ignore();
cout<<“You have entered an invalid input!”<<endl;
cout << “Power Supply Watts: “;
cin >> pc1.powerSupply;
}
if(!cin.fail())
break;
}
cout << “\nEnter Components for PC2” << endl << endl;
cout << “Mainboard Brand: “;
getline (cin >> ws, pc2.mainboard);
cout << “Number of Processor Cores: “;
cin >> pc2.processorCore;
while(1)
{
if(cin.fail())
{
cin.clear();
cin.ignore();
cout<<“You have entered an invalid input!”<<endl;
cout << “Number of Processor Cores: “;
cin >> pc2.processorCore;
}
if(!cin.fail())
break;
}
cout << “Ram Size in Gb: “;
cin >> pc2.ramSize;
while(2)
{
if(cin.fail())
{
cin.clear();
cin.ignore();
cout<<“You have entered an invalid input!”<<endl;
cout << “Ram Size in Gb: “;
cin >> pc2.ramSize; }
if(!cin.fail())
break;
}
cout << “Hard Drive Storage in Gb: “;
cin >> pc2.hardDrive;
while(3)
{
if(cin.fail())
{
cin.clear();
cin.ignore();
cout<<“You have entered an invalid input!”<<endl;
cout << “Hard Drive Storage in Gb: “;
cin >> pc2.hardDrive;
}
if(!cin.fail())
break;
}
cout << “Power Supply Watts: “;
cin >> pc2.powerSupply;
while(4)
{
if(cin.fail())
{
cin.clear();
cin.ignore();
cout<<“You have entered an invalid input!”<<endl;
cout << “Power Supply Watts: “;
cin >> pc2.powerSupply;
}
if(!cin.fail())
break;
}
cout << “\nEnter Components for PC3” << endl << endl;
cout << “Mainboard Brand: “;
getline (cin >> ws, pc3.mainboard);
cout << “Number of Processor Cores: “;
cin >> pc3.processorCore;
while(1)
{
if(cin.fail())
{
cin.clear();
cin.ignore();
cout<<“You have entered an invalid input!”<<endl;
cout << “Number of Processor Cores: “;
cin >> pc3.processorCore;
}
if(!cin.fail())
break;
}
cout << “Ram Size in Gb: “;
cin >> pc3.ramSize;
while(2)
{
if(cin.fail())
{
cin.clear();
cin.ignore();
cout<<“You have entered an invalid input!”<<endl;
cout << “Ram Size in Gb: “;
cin >> pc3.ramSize;
}
if(!cin.fail())
break;
}
cout << “Hard Drive Storage in Gb: “;
cin >> pc3.hardDrive;
while(3)
{
if(cin.fail())
{
cin.clear();
cin.ignore();
cout<<“You have entered an invalid input!”<<endl;
cout << “Hard Drive Storage in Gb: “;
cin >> pc3.hardDrive;
}
if(!cin.fail())
break;
}
cout << “Power Supply Watts: “;
cin >> pc3.powerSupply;
while(4)
{
if(cin.fail())
{
cin.clear();
cin.ignore();
cout<<“You have entered an invalid input!”<<endl;
cout << “Power Supply Watts: “;
cin >> pc3.powerSupply; }
if(!cin.fail())
break;
}
cout << “\nEnter Components for PC4” << endl << endl;
cout << “Mainboard Brand: “;
getline (cin >> ws, pc4.mainboard);
cout << “Number of Processor Cores: “;
cin >> pc4.processorCore;
while(1)
{
if(cin.fail())
{
cin.clear();
cin.ignore();
cout<<“You have entered an invalid input!”<<endl;
cout << “Number of Processor Cores: “;
cin >> pc4.processorCore;
}
if(!cin.fail())
break;
}
cout << “Ram Size in Gb: “;
cin >> pc4.ramSize;
while(2)
{
if(cin.fail())
{
cin.clear();
cin.ignore();
cout<<“You have entered an invalid input!”<<endl;
cout << “Ram Size in Gb: “;
cin >> pc4.ramSize;
}
if(!cin.fail())
break;
}
cout << “Hard Drive Storage in Gb: “;
cin >> pc4.hardDrive;
while(3)
{
if(cin.fail())
{
cin.clear();
cin.ignore();
cout<<“You have entered an invalid input!”<<endl;
cout << “Hard Drive Storage in Gb: “;
cin >> pc4.hardDrive;
}
if(!cin.fail())
break;
}
cout << “Power Supply Watts: “;
cin >> pc4.powerSupply;
while(4)
{
if(cin.fail())
{
cin.clear();
cin.ignore();
cout<<“You have entered an invalid input!”<<endl;
cout << “Power Supply Watts: “;
cin >> pc4.powerSupply;
}
if(!cin.fail())
break;
}
cout << “\nEnter Components for PC5” << endl << endl;
cout << “Mainboard Brand: “;
getline (cin >> ws, pc5.mainboard);
cout << “Number of Processor Cores: “;
cin >> pc5.processorCore;
while(1)
{
if(cin.fail())
{
cin.clear();
cin.ignore();
cout<<“You have entered an invalid input!”<<endl;
cout << “Number of Processor Cores: “;
cin >> pc5.processorCore;
}
if(!cin.fail())
break;
}
cout << “Ram Size in Gb: “;
cin >> pc5.ramSize;
while(2)
{
if(cin.fail())
{
cin.clear(); cin.ignore();
cout<<“You have entered an invalid input!”<<endl;
cout << “Ram Size in Gb: “;
cin >> pc5.ramSize;
}
if(!cin.fail())
break;
}
cout << “Hard Drive Storage in Gb: “;
cin >> pc5.hardDrive;
while(3)
{
if(cin.fail())
{
cin.clear();
cin.ignore();
cout<<“You have entered an invalid input!”<<endl;
cout << “Hard Drive Storage in Gb: “;
cin >> pc5.hardDrive;
}
if(!cin.fail())
break;
}
cout << “Power Supply Watts: “;
cin >> pc5.powerSupply;
while(4)
{
if(cin.fail())
{
cin.clear();
cin.ignore();
cout<<“You have entered an invalid input!”<<endl;
cout << “Power Supply Watts: “;
cin >> pc5.powerSupply;
}
if(!cin.fail())
break;
}
cout << “\n ——————————– \n”;
cout << “| Overview of PC Components |\n”;
cout << ” ——————————– \n\n”;
cout << setw(2) << ” ” << setfill (‘-‘) << setw(115) << “-” << endl;
cout << fixed << setprecision(2) << setfill (‘ ‘);cout << setw(2) << ” ” << “| Component | ” <<
setw(14) << “| PC 1 |”
<< setw(18) << “| PC 2 |” << setw(18) << “| PC 3 |” << setw(18) << “| PC 4 |”
<< setw(18) << “| PC 5 |” << endl << endl;
cout << setw (4) << ” ” << setw(9) << “Mainboard” << setw(18) << ” ”
<< pc1.mainboard << setw(10) << ” ” << left
<< pc2.mainboard << setw(10) << ” ” << left
<< pc3.mainboard << setw(10) << ” ” << left
<< pc4.mainboard << setw(10) << ” ” << left
<< pc5.mainboard << setw(10) << ” ” << left << endl;
cout << setw (4) << ” ” << setw(9) << “Processor Cores” << setw(12) << ” ”
<< pc1.processorCore << ” cores” << setw(11) << ” ” << left
<< pc2.processorCore << ” cores” << setw(11) << ” ” << left
<< pc3.processorCore << ” cores” << setw(11) << ” ” << left
<< pc4.processorCore << ” cores” << setw(11) << ” ” << left
<< pc5.processorCore << ” cores” << setw(10) << ” ” << left
<< endl;
cout << setw (4) << ” ” << setw(9) << “Ram (GB)” << setw(18) << ” ”
<< pc1.ramSize << ” Gb” << setw(13) << ” ” << left
<< pc2.ramSize << ” Gb” << setw(13) << ” ” << left
<< pc3.ramSize << ” Gb” << setw(13) << ” ” << left
<< pc4.ramSize << ” Gb” << setw(13) << ” ” << left
<< pc5.ramSize << ” Gb” << setw(13) << ” ” << left
<< endl;
cout << setw (4) << ” ” << setw(7) << “Hard Drive (GB)” << setw(12) << ” ”
<< pc1.hardDrive << ” Gb” << setw(12) << ” ” << left
<< pc2.hardDrive << ” Gb” << setw(12) << ” ” << left
<< pc3.hardDrive << ” Gb” << setw(12) << ” ” << left
<< pc4.hardDrive << ” Gb” << setw(12) << ” ” << left
<< pc5.hardDrive << ” Gb” << setw(12) << ” ” << left
<< endl;
cout << setw (4) << ” ” << setw(9) << “Power Supply (Watts)” << setw(7) << ”
”
<< pc1.powerSupply << ” Watts” << setw(9) << ” ” << left
<< pc2.powerSupply << ” Watts” << setw(9) << ” ” << left
<< pc3.powerSupply << ” Watts” << setw(9) << ” ” << left
<< pc4.powerSupply << ” Watts” << setw(9) << ” ” << left
<< pc5.powerSupply << ” Watts” << setw(9) << ” ” << left
<< endl;
cout << setw(2) << ” ” << setfill (‘-‘) << setw(115) << “-” << setfill (‘ ‘) << endl
<< left;
return 0;
}else if (input == “n” || input == “N”)
{
system (“clear”);
cout << “\nOh my apologies! Goodbye! \n”;
return 0;
}
cout << “Thank you for placing your order!”;
return 0;
}
Stuck in Completing this Assignment and feeling stressed ? Take our Private Writing Services.
Get Help By Expert
Assignmenthelper.my is the ultimate homework help online platform. We provide students with high-quality and affordable services that ensure success in their homework and assignments. With our exceptional writing service, you can take your studies to a higher level without having to worry about getting good grades.
Recent Solved Questions
- Business Economics Assignment, UMS, Malaysia I’VE DEVOTED MOST OF MY life to working for the poorest people, particularly the poorest women, trying to remove
- Programming Fundamental Assignment, TU, Malaysia Morgan Stark is a child prodigy just like his father Tony Stark when he was young. At five years old, she self-taught herself
- Pedagogical Implication on Student’s Performance in English Home Work, UO, Malaysia A number of studies done concerning the language of instruction and students‟ performance in secondary schools
- DBM5024 Business Finance Assignment, MMU, Malaysia King Bakery is evaluating two different projects to expand its business The first project, Project Nutmeg has an initial cost of RM12,000
- STA404: Statistics for Business and Social Sciences Assignment, UiTM, Malaysia Healthcare facilities are essential for providing quality and accessible health services to the population
- AUD339: Auditing Assignment, UiTM, Malaysia In the past, there have been issues regarding how internal auditors want to audit the company and profession in relation
- Professional Engineering Techniques Home Work, APU, Malaysia Calculate the shortest payback period for the project investment shown in Table 1. Which project has a better investment
- BBGO4103: The purpose of this assignment is to enhance learners’ ability to apply and adapt the concept and theories of organisational behaviour: Organisational Behaviour, Assignment, OUM, Malaysia
- BBPB2103: HUMAN RESOURCE MANAGEMENT Assignment, OUM, Malaysia The purpose of this assignment is to enhance learners’ ability to explain the disciplinary procedures and challenges in taking disciplinary
- Circuit Analysis Assignment, CUCST, Malaysia Each group needs to design its own circuitry to wire the electric radiators to the power supplied to the garage