I am storing Box State as Boolean and Printing Closed Box
Numbers and Total Closed Boxes
Result:

Files:

Code (Text Code also included in End):
![2 3 #include <iostream> using namespace std; int main() // Initializing Variables const int boxes = 150; bool states[boxes];](http://img.homeworklib.com/questions/cf7ef3e0-c4e7-11eb-8be5-d1876d6c12cc.png?x-oss-process=image/resize,w_560)
Code:
#include <iostream>
using namespace std;
int main()
{
// Initializing Variables
const int boxes = 150;
bool states[boxes];
// Closing All Boxes
for(int i = 0; i < boxes; i++){
states[i] = false;
}
// Changing States of Alternate Boxes
for(int i = 2; i <= boxes; i++){
for(int j = i; j <= boxes;
j += i){
// Reversing State
states[j - 1] =
!states[j - 1];
}
}
// Print Closed Box Numbers
int totalClosed = 0;
cout << "Closed Box Numbers:\n";
for(int i = 0; i < boxes; i++){
if (!states[i]){
cout << (i + 1)
<< " ";
totalClosed += 1;
}
}
cout << "Total Closed Boxes:" << totalClosed;
return 0;
}
CSCI 111 Assignment 4 Aim: To write some programs using loops, arrays and library functions. Procedure:...
Assume that we are writing a game like Minecraft in C++. We will have a World class that stores a 3-dimensional array of "Voxels". A voxel is a simple element of volume (think Pixel, but 3D). Your task for this assignment is to create a world, set some Voxels and display them. You are provided with a simple class for a Voxel that stores a RGB color value, as well as a character code for the type of element. You...
Assignment 6: Recursion Learning Outcomes • Learn how to craft solutions using recursion instead of loops. Instructions This assignment will be different than previous assignments (and most assignments which come after it). In this assignment, you will be crafting four solutions to four different problems. This assignment will also have special requirements regarding how you may code. You are not allowed to use assignment statements. This includes using preincement, postincrement, predecrement, and postdecrement. You are allowed to use assignment to...
can i get some help with this program
CMPS 12B Introduction to Data Structures Programming Assignment 2 In this project, you will write a Java program that uses recursion to find all solutions to the n-Queens problem, for 1 Sns 15. (Students who took CMPS 12A from me worked on an iterative, non-recursive approach to this same problem. You can see it at https://classes.soe.ucsc.edu/cmps012a/Spring l8/pa5.pdf.) Begin by reading the Wikipcdia article on the Eight Queens puzzle at: http://en.wikipedia.org/wiki/Eight queens_puzzle In...
We learn arrays (and Arrays class) in Chapter 10 and ArrayList collection in Chapter 14. This assignment asks you to re-do Assignment 4 by using arrays and ArrayList collections to deliver exactly the same output. The input also stays the same, which are two argument values entered at the command line when 'java' command is issued. With the use of these data structures that help to store data in certain way, you are not going to print each character immediately...
Note: None of these functions should use cout. It is OK to use cout while debugging to check how your function is working, but your final submission should not contain cout in any function but main. Head ==== Name the source file for this section head.cpp. Write a function named "head" which takes an array of integers as an argument, and returns the first element in the array. Write a function named main which outputs the result of testing your...
I would like some assistance correcting an issue I am having with this assignment. Once a finite state automaton (FSA) is designed, its transition diagram can be translated in a straightforward manner into program code. However, this translation process is considerably tedious if the FSA is large and troublesome if the design is modified. The reason is that the transition information and mechanism are combined in the translation. To do it differently, we can design a general data structure such...
This assignment should give you experience in using file descriptors, open(), close(), write(), stat() and chmod(), perror(), and command line arguments. Program: Write a C++ program that will allow you to add messages to a file that has NO permissions for any user. A Unix system has many files that have sensitive information in them. Permissions help keep these files secure. Some files can be publicly read, but can not be altered by a regular user (ex.: /etc/passwd). Other files...
1.2 Recruitment is one of the crucial functions of HRM. Based on the information provided below, how would you describe THE COMPANY’s approach to recruitment, before and after the implementation of the Brand Ambassador Program? How did the use of social media lead to the revision of the whole approach regarding recruitment? How ‘THE COMPANY’ Developed a Brand Ambassador Program At ‘THE COMPANY’ we usually categorize Employment Brand at ‘THE COMPANY’ into four big ‘buckets’: candidate experience, brand ambassador programs,...
Objective: Write a program that implements the Game of Life cellular automata system invented by John Conway. 1. Create two game grids of size at least 50x50. These grid cells can be either Boolean or integer. In the following, I’ll refer to these as gridOne and gridTwo. 2. Set all cells in both grids to false. 3. Start by initializing gridOne. Allow the user to specify two different ways of initializing the grid: 1) by specifying a pattern file to...
Solve it for java
Question Remember: You will need to read this assignment many times to understand all the details of the you need to write. program Goal: The purp0se of this assignment is to write a Java program that models an elevator, where the elevator itself is a stack of people on the elevator and people wait in queues on each floor to get on the elevator. Scenario: A hospital in a block of old buildings has a nearly-antique...