Question

In: Computer Science

C++ For the assignment, we will use the previous assignment’s program that determines whether a college...

C++

For the assignment, we will use the previous assignment’s program that determines whether a college class room is in violation of fire law regulations regarding the maximum room capacity and add more logic to that program. We will need to make the following enhancements…

  • Convert all of the function’s parameters from pass by value to pass by reference.

  • Accumulate totals for each of the class rooms that we are using for this program. When the program ends (user choice of 6), display those totals for each class room before you return 0 in main.

  • Create local scope variables in main for the totals, and return them back to main for displaying them.

  • You should reuse code (the same function) for determining percentage of capacity remaining.

Match your program with the sample output as shown below.

the following now displays after user entry to quit …

For Leigh Hall room 312:

Your total is 687 out of 700 and there is minimal 1.86% capacity remaining

For College of Arts and Sciences room 41:

Your total is 220 out of 225 and there is minimal 2.23% capacity remaining

Remember that your program still has the same functionality as before, has a menu, etc. Make sure that your programs follow good documentation standards and follow the requirements for assignments. Reference the rubric standards on Brightspace. Do not use namespace std!!!!!!!!!!!!!!!!!.

previous program below:

#include
using namespace std;

//to check which class user wants to have
void checkClass(string message,int capacity)
{
cout< cout<<"Enter the number of attendes: ";
int atten;
cin>>atten;
if(atten>capacity)
{
cout<<"The class cannot be held as planned\n";
}
else
{
float perc = 100.0-(((float)(atten)/capacity )*100);
cout<<"It is legal to hold class and there is minimal "< }

}


int main()
{
int classes,attendees,room;
int choice; //input for user choice;
while(true)
{
//display the menu
cout<<" Please choose a room from the menu\n";
cout<<"1.Leigh Hall room 312\n";
cout<<"2.College of Arts and Sciences room 41\n";
cout<<"3.Kolbe Hall room 133\n";
cout<<"4.Whitby Hall room 111\n";
cout<<"5.Ayer Hall room 30\n";
cout<<"6.Quit\n";

while(true)
{
cout<<"Enter the room for your class 1 (1-6): ";
cin>>choice;
if(choice<=0||choice>6)
cout<<"Invalid choice\n";
else
break;
}

switch(choice)
{
case 1: checkClass("Leigh Hall room 312",312);
break;
case 2: checkClass("College of Arts and Sciences room",41);
break;
case 3: checkClass("Kolbe Hall room",133);
break;
case 4: checkClass("Whitby Hall room",111);
break;
case 5: checkClass("Ayer Hall room",30);
break;
case 6: cout<<"Bye";
return 0;;
break;

}
}
return 0;
}

the code that i put in here is the previous program that was used in the previous assignment.

Solutions

Expert Solution

#include <iostream>
#include <string.h>

//to check which class user wants to have
/*
* Arrays Are never passes by value. These are already passed by reference
* capacity (formal argument) is not altered within the function. Hence it is not reflected in the actual argument
* changing return type to cater to the requirement of returning total back to main.
*/
int checkClass(char message[], int& capacity)
{
   cout << "Enter the number of attendes: ";
   int atten;
   cin >> atten;
   if (atten > capacity)
   {
       cout << "The class cannot be held as planned\n";
   }
   else
   {
       float perc = 100 - ((atten * 100) / (float)capacity);
       cout << "It is legal to hold class and there is minimal " << perc << " capacity remaining\n";
   }
   return atten;
}


int main()
{
   int classes, attendees, room;
   int choice; //input for user choice;

//LOCAL VARIABLES DECLARED IN MAIN//
   int defvalues[] = { 312, 41, 133, 111, 30 };
   int capacities[5] = { 0 };

   while (true)
   {
       //display the menu
       cout << " Please choose a room from the menu\n";
       cout << "1.Leigh Hall room 312\n";
       cout << "2.College of Arts and Sciences room 41\n";
       cout << "3.Kolbe Hall room 133\n";
       cout << "4.Whitby Hall room 111\n";
       cout << "5.Ayer Hall room 30\n";
       cout << "6.Quit\n";

       while (true)
       {
           cout << "Enter the room for your class 1 (1-6): ";
           cin >> choice;
           if (choice <= 0 || choice > 6)
               cout << "Invalid choice\n";
           else
               break;
       }

       switch (choice)
       {
       case 1: capacities[choice - 1] = checkClass((char*)"Leigh Hall room 312", defvalues[choice-1]);
           break;
       case 2: capacities[choice - 1] = checkClass((char*)"College of Arts and Sciences room", defvalues[choice - 1]);
           break;
       case 3: capacities[choice - 1] = checkClass((char*)"Kolbe Hall room", defvalues[choice - 1]);
           break;
       case 4: capacities[choice - 1] = checkClass((char*)"Whitby Hall room", defvalues[choice - 1]);
           break;
       case 5: capacities[choice - 1] = checkClass((char*)"Ayer Hall room", defvalues[choice - 1]);
           break;
       case 6:
           cout << "\nFor Leigh Hall room 312:\nYour total is " << capacities[0] << " out of" << defvalues[0]
               << " and there is minimal " << 100 - ((capacities[0] * 100) / (float)defvalues[0]) << " capacity remaining";

           cout << "\nFor College of Arts and Sciences room:\nYour total is " << capacities[1] << " out of " << defvalues[1]
               << " and there is minimal " << 100 - ((capacities[1] * 100) / (float)defvalues[1]) << " capacity remaining";

           cout << "\nKolbe Hall room:\nYour total is " << capacities[2] << " out of" << defvalues[2]
               << " and there is minimal " << 100 - ((capacities[2] * 100) / (float)defvalues[2]) << " capacity remaining";

           cout << "\nWhitby Hall room:\nYour total is " << capacities[3] << " out of" << defvalues[3]
               << " and there is minimal " << 100 - ((capacities[3] * 100) / (float)defvalues[3]) << " capacity remaining";

           cout << "\nAyer Hall room:\nYour total is " << capacities[4] << " out of" << defvalues[4]
               << " and there is minimal " << 100 - ((capacities[4] * 100) / (float)defvalues[4]) << " capacity remaining";
           cout << "\nBye";
           return 0;
       }
   }
   return 0;
}


Related Solutions

C++ For the assignment, we will use the previous assignment’s program that determines whether a college...
C++ For the assignment, we will use the previous assignment’s program that determines whether a college class room is in violation of fire law regulations regarding the maximum room capacity and add more logic to that program. We will need to make the following enhancements… For each new class entry that is taken, you will write out the information to a file. The file can be any .txt file name of your choosing. The file should be appended to each...
C++ For the assignment, we will use the previous assignment’s program that determines whether a college...
C++ For the assignment, we will use the previous assignment’s program that determines whether a college class room is in violation of fire law regulations regarding the maximum room capacity and add more logic to that program. We will need to make the following enhancements… Convert all of the function’s parameters from pass by value to pass by reference. Accumulate totals for each of the class rooms that we are using for this program. When the program ends (user choice...
Use Excel to answer. A college admission officer for an MBA program determines that historically candidates...
Use Excel to answer. A college admission officer for an MBA program determines that historically candidates have undergraduate grade averages that are normally distributed with standard deviation of .45. A random sample of 25 applications from the current year yields a sample mean grade point average of 2.90. Find a 95% confidence interval for the population mean, μ. (Round the boundaries to 2 decimal places.) Based on the same sample results, a statistician computes a confidence interval for the population...
Programming Assignment #2, Processes Write a C program (time_shm.c) that determines the amount of time necessary...
Programming Assignment #2, Processes Write a C program (time_shm.c) that determines the amount of time necessary to run a command from the command line. This program will be run as ./time <command [args...]> and will report the amount of elapsed time to run the specified command. This will involve using fork() and execvp() functions, as well as the gettimeofday() function to determine the elapsed time. It will also require the use of two different IPC mechanisms. The general strategy is...
Write a program that determines whether an input string is a palindrome; that is, whether it...
Write a program that determines whether an input string is a palindrome; that is, whether it can be read the same way forward and backward. At each point, you can read only one character of the input string; do not use an array to first store this string and then analyze it (except, possibly, in a stack implementation). Consider using multiple stacks. In Pseudocode please
This C++ assignment asks to write a function that determines if a C-string begins with a...
This C++ assignment asks to write a function that determines if a C-string begins with a specified prefix. It should have the following signature: bool starts(char *str, char *prefix) It should return true if str begins with prefix, false if not. It should return false if prefix is longer than str. See the table below for some examples of what your function should return for various cases: str prefix returns airplanes air true airplanes abc false airplanes plane false airplanes...
Program Assignment 1 C++ please Instructions This assignment will require the use of three arrays, which...
Program Assignment 1 C++ please Instructions This assignment will require the use of three arrays, which will be used in parallel. Create a program that keeps track of the sales of BBQ sauces for a company. The company makes several different types of sauces, Original, Sticky Sweet, Spicy, Sweet Heat, Hickory Bourbon and Smokey Mesquite. One array will contain the names of the different BBQ sauces. This array will be initialized from a text file with the 6 different names....
c++ program You are to use a Heap data structure for this assignment I currently work...
c++ program You are to use a Heap data structure for this assignment I currently work for an investment/insurance company and I’m looking for clients to call, ones with funds.  I need to have a schedule that shows the list of customers to call and the order to be called.  The list of customers names and phone numbers are in the file ‘NamesAndPhoneV2.txt’.  A second file contains a net worth value for each client.  The files are separated for security and protection reasons, but...
designing a multithreaded application in C that determines whether the solution to a Sudoku puzzle is...
designing a multithreaded application in C that determines whether the solution to a Sudoku puzzle is valid A Sudoku puzzle uses a 9×9 grid in which each column and row, as well as each of the nine 3×3 subgrids, must contain all of the digits 1 to 9. main.c #include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h> int puzzle[PUZZLE_SIZE+1][PUZZLE_SIZE+1]; int status_map[NUMBER_OF_THREADS];    parameters* worker_params[NUMBER_OF_THREADS]; pthread_t workers[NUMBER_OF_THREADS]; int main(int argc, char** argv) {    //Read the sudoku solution from  the file specified...
Compute in excel A college admission officer for an MBA program determines that historically candidates have...
Compute in excel A college admission officer for an MBA program determines that historically candidates have undergraduate grade averages that are normally distributed with standard deviation of .45. A random sample of 25 applications from the current year yields a sample mean grade point average of 2.90. (i) Find a 95% confidence interval for the population mean, μ. (Round the boundaries to 2 decimal places.) (ii) Based on the same sample results, a statistician computes a confidence interval for the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT