Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hi, please convert this C++ code into Shell Script (Unix/Linux) using namespace std; int main() { // random number generator srand(time()); // defining objects for
Hi, please convert this C++ code into Shell Script (Unix/Linux)
using namespace std; int main() { // random number generator srand(time()); // defining objects for mathreport & mathoperations MathReport r; MathOperations q; // declaring / initializing variables int choice; int numberone = ; int numberTwo = 0; int studentAnswer; // while loop for displaying menu while(choice != 4){ // printing menu cout > choice; // ignoring for blank line if(cin.peek() == ' '){ cin.ignore(); // if not int or if less than one or greater than four, invalid 1/ recieved help for this statement if(cin.fail() || choice 4){ cout > studentAnswer; // ignoring cin.ignore(200, ' '); // while cin fails while(cin.fail(){ // clearing & ignoring cin.clear(); sin ignore(200, ' '); // invalid statement cout > studentAnswer; cin.ignore(200, ' '); // if statement for if the answer is right if(q.checkAnswer( studentAnswer)){ // congrats statement cout > studentAnswer; 17 ignoring cin. ignore(200,' '); 1/input validation loop while (cin.fail()) { // clearing cin.clear(); // ignoring cin. ignore (200, ' '); // invalid statement cout > studentAnswer; // ignoring again cin. ignore(200, ' '); // if answer is correct if (q.checkAnswer(studentAnswer)) // congrats statement cout > studentAnswer; // ingoring, again sin ignore(200,' '); //input validation loop while (cin.fail()){ // clearing cin.clear(); // ignoring cin.ignore (200, ' '); // invalid statement cout > studentAnswer; // ignoring again cin.ignore(200, ' '); // if the answer is correct if (q.checkAnswer student Answer)) 11 congrats statement cout > choice; // ignoring for blank line if(cin.peek() == ' '){ cin.ignore(); // if not int or if less than one or greater than four, invalid 1/ recieved help for this statement if(cin.fail() || choice 4){ cout > studentAnswer; // ignoring cin.ignore(200, ' '); // while cin fails while(cin.fail(){ // clearing & ignoring cin.clear(); sin ignore(200, ' '); // invalid statement cout > studentAnswer; cin.ignore(200, ' '); // if statement for if the answer is right if(q.checkAnswer( studentAnswer)){ // congrats statement cout > studentAnswer; 17 ignoring cin. ignore(200,' '); 1/input validation loop while (cin.fail()) { // clearing cin.clear(); // ignoring cin. ignore (200, ' '); // invalid statement cout > studentAnswer; // ignoring again cin. ignore(200, ' '); // if answer is correct if (q.checkAnswer(studentAnswer)) // congrats statement cout > studentAnswer; // ingoring, again sin ignore(200,' '); //input validation loop while (cin.fail()){ // clearing cin.clear(); // ignoring cin.ignore (200, ' '); // invalid statement cout > studentAnswer; // ignoring again cin.ignore(200, ' '); // if the answer is correct if (q.checkAnswer student Answer)) 11 congrats statement coutStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started