Question
C++ Write a program that randomly moves a student from one seat to another seat in a lecture hall, perhaps to randomly move students before
C++
Write a program that randomly moves a student from one seat to another seat in a lecture hall, perhaps to randomly move students before an exam. The seats are in 20 rows numbered 1 to 20. Each row has 30 seats (columns) numbered 1 to 30. The student should be moved from the left side (columns 1 to 15) to the right side (columns 16 to 30). Given an input of row number and column number, the program should randomly allocate the student in a spot on the right. The program should output the old and new row and column number. This program does not use arrays or loops
Here is a starter template for you:
#include
// Switch a student // from a random seat on the left (cols 1 to 15) // to a random seat on the right (cols 16 to 30) // Seat rows are 1 to 20
int main() { int rowNumL; //row number on the left int colNumL; //column number on the left int rowNumR; // row number on the right int colNumR; // colum number on the right
// your code goes in here
cout << "Move from "; cout << "row " << rowNumL << " col " << colNumL; cout << " to " ; cout << "row " << rowNumR << " col " << colNumR; cout << endl;
return 0; }
Step 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