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
- Co-curricular Activity Assignment, TARC, Malaysia Critically evaluate how co-curricular activities for intellectual development are implemented in schools
- LGP7084: Mergers & Acquisition Assignment, VUC, Malaysia AHJ is a Malaysian public listed company listed on the Main Market of Bursa Malaysia Securities Berhad
- MPU3123: Islamic Civilization and Asian Civilization Assignment, AeU, Malaysia Kerajaan Islam zaman Abbasiyyah telah membawa perubahan yang besar dalam pelbagai aspek seperti perubatan
- Customers enter the waiting line at a cafeteria’s only cash register on a first-come, first-served basis: Optimization Technique Assignment, UMP, Malaysia
- BUSM50003: Big Data Research Paper, SU, Malaysia Explain your research philosophy and methodologies and In particular, comment on the research design
- XBMB3104: MICROBIOLOGY Assignment, OUM, Malaysia you are appointed to give a briefing on the tiers of recommended precautions to prevent the spread of infections in healthcare settings
- MPU3123/03: Tamadun Islam dan Tamadun Asia Assignment, WOU, Malaysia Anda diminta untuk mengepilkan satu foto yang menonjolkan impak interaksi antara tamadun
- MEC4401: Mechanical Engineering Thesis, MUM, Malaysia To evaluate the clay type and study the rheology behavior of different water content in the clay
- Business Intelligence and Analytics Systems Assignment, TU, Malaysia Find recent cases of successful text mining and Web mining applications. Visit the websites of some text
- AFT1083: Microeconomics Case Study, UMK, Malaysia Refined sugar producer MSM Malaysia Holdings Bhd’s profitability may be affected if the new government lowers