Answer:
C++
Explanation:
class MyBoxes {
private:
// Pointer to Box object and array size. Required for dynamically creating an array.
Box* boxes;
int array_size;
// Constructor
MyBoxes(int array_size) {
self.array_size = array_size;
boxes = new Box[array_size] ;
}
public:
// Methods
int emptyspace() {
int count = 0;
for (int i=0; i < self.array_size; i++) {
// Check for null
if (!boxes[i])
count++;
}
return count;
}
void add(int length, int width, int height) {
Box box1(length, width, height);
if (self.emptyspace() == 0) {
self.addToArray(box1);
}
}
void print() {
Box *temporaryBox;
for (int i=0; i < self.array_size; i++) {
temporaryBox = boxes[i];
if (temporaryBox) {
cout<<temporaryBox->length<<endl;
cout<<temporaryBox->width<<endl;
cout<<temporaryBox->height<<endl;
}
}
// Free memory
delete temporaryBox;
}
Answer:
import java.util.Scanner;
public class num1 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
//Prompt and receive user input
System.out.println("Enter number of Steps");
int numSteps = in.nextInt();
double numMiles = numSteps/2000;
//Print the formated number of miles
System.out.printf("The equivalent miles is %.2f ",numMiles);
}
}
Explanation:
- This is solved using Java programming language
- Scanner class is imported and used to receive user input (number of steps walked)
- To convert number of steps to number of miles, we divide by 2000, Since the question says the pedometer treats walking 2,000 steps as walking 1 mile.
- Output the number of miles to 2 decimal places using java's printf() method
I think they should join the military.
It is free, so they don't have to think about spending too much money on various courses. And obviously, they will be serving their nation if they are in the military. Online courses won't give them hands on experience, and your other options aren't free.