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
- ACC4054: Critically discuss the importance of standardization of accounting standards for listed companies: Financial Accounting 5, Assignment, APU, Malaysia
- 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
- MPMM7113: You have a friend named David who is a passionate environmentalist and runs a small eco-friendly products store: Davideting Management Assignment 2, CUM, Malaysia
- BKAN1013 Basic Accounting Assignment, UUM, Malaysia Gurkha Consultancy Sdn Bhd is a company that provides consultation to entrepreneurs
- ADS553: Strategic Management For Public Sector Report, UiTM, Malaysia Your task is to prepare a proper presentation together with a written report on any newspaper articles discussing various projects
- Networks and Networking Assignment, APU, Malaysia You are required to design and apply an IP addressing scheme for the topology shown for the Aman Resort network
- BBM104: Principles of Marketing Case Study, UT, Malaysia Once a major tourist attraction, the zoo appears to be back on its feet after the pandemic but is still in need of a revamp
- CIVE2313: Fluid Mechanics Assignment, IIUM, Malaysia A horizontal pipe of 25 cm 600 cm long is connected to a water reservoir at one end and discharged freely
- Implement (code) any of the searching and sorting algorithms: Data Structures & Algorithms, Assignment, MUST, Malaysia
- Law Equity & Trust Assignment, IIUM, Malaysia Leo Pedersen and Calvin Pedersen are brothers. In 2010, Leo left his job to set up Viking Oak Software Ltd