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
- BBF305/03: Investment and Portfolio Management Assignment, WOU, Malaysia Suppose there are an infinite number of assets with an expected return of 12% p a and a standard deviation
- BPMG3033: Urban and rural transport management Case Study, UUM, Malaysia What type of transportation mode should be used by ORKID to manage the distribution of their products to the customers
- BBMF 3073: Risk Management Assignment, UTAR, Malaysia Risk Management analysis is the discipline of identifying business risk and determining solutions to business risk
- BBUS2103: The purpose of this assignment is to enhance learners’ ability to discuss the principles related to members of a company: Company Law, Assignment, OUM, Malaysia
- Alternative dispute resolution Essay, IIUM. Malaysia In Malaysia, there are two different types of mediation practices Firstly, mediation is available in the court
- HRM3183: Omega, Inc., is a small manufacturing company whose sales success or failure rests in the hands: Performance Management Case Study, UPTM, Malaysia
- HPGD1103: What impact do you think new technologies are having on the way curricula are developed and delivered?: Curriculum Development Assignment, Malaysia
- Hydrology Assignment, UITM, Malaysia Direct Runoff Hydrograph (DRH) was observed from the urbanized catchment and rural catchment less than 10% development
- Entrepreneurship Assignment, SU, Malaysia By focusing on its strengths, its key customers, and the company’s underlying core values, Acme Management Technology
- A critical analysis of differing strategic perspectives of producers, retailers and logistics service providers: Essay, UUM, Malaysia