Create a C++ or Java program that will select students from the last attendance login to answer a question.
NOTE: program execution should include deletion and insertion of attendance information/element
Program Code in C++ Screenshot
Program Sample Console Input/Output Screenshot
Program Code to Copy
#include <bits/stdc++.h>
using namespace std;
int main()
{
//create a stack to store all elements in a last in first out system
stack<string> list;
// variable to take user choice in a menu driven program
int choice;
do
{
//print menu
cout << "Enter option 1/2?" << endl;
cout << "1. Login Student" << endl;
cout << "2. Select a students from last attendance login." << endl;
cout << "3. Exit." << endl;
//take user input
cin >> choice;
if (choice == 1)
{
//get login student name
cout << "Enter Student Name: ";
string name;
cin >> name;
//push stuent in stack
list.push(name);
//show message
cout << "Logged in student: " << name << endl;
}
else if (choice == 2)
{
if (list.empty())
{
cout << "No student left to ask question" << endl;
continue;
}
//get student from the stack
string student = list.top();
//pop the stack
list.pop();
//show student selected
cout << "Selected student from last login: " << student << endl;
}
} while (choice != 3);
}
Get Answers For Free
Most questions answered within 1 hours.