Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In C++ Implement each function prototyped in functions.h that has a TODO. You may assume the precondition is ALWAYS met, you do not need to
In C++
Implement each function prototyped in functions.h that has a TODO. You may assume the precondition is ALWAYS met, you do not need to confirm the precondition is true. You may NOT use stoi, atoi, stringstream, or any includes other than cmath, string, iostream, and iomanip.
starter functions.cpp
#include#include #include #include #include "functions.h" unsigned long long collatzConjectureSteps(unsigned long long) { return 0; //TODO: remove this stub when implemented } //Precondition: n > 0, Postcondition: Returns the number of steps it takes to transform a given integer to 1 using Collatz Conjecture bool isLeapYear(unsigned short) { return false; //TODO: remove this stub when implemented } //Precondition: none, Postcondition: Returns true if integer is a leap year, false otherwise bool isInteger(const std::string &s) { return true; //TODO: remove this stub when implemented } //Precondition: none, Postcondition: (1) Returns true if the passed string represents a integer with or without commas (2) If the integer has at least one comma, the entire integer has commas in groups of 3 (3) Supports negative numbers as long as no padding with spaces (4) All strings containing non numeric digits, hyphen in more than just the first position, or commas in the incorrect spots will return false long long stringToLong(const std::string& s) { return 0; //TODO: remove this stub when implemented } //Precondition: n > 0, Postcondition: Returns the number of steps it takes to transform a given integer to 1 using Collatz Conjecture void swapNumbers(long& x, long& y) { //TODO } //Precondition: None, Postcondition: The value in x is copied to y and y gets the former value of x double standardDeviation(const double nums[], unsigned int count) { return 0; //TODO: remove this stub when implemented } //Precondition: num is an array of count size, Postcondition: returns the calculated standard deviation of all the numbers in the array void printArray(const double nums[], unsigned int count, unsigned short precision/*=3*/ ) { //TODO } //Precondition: nums is an array of count size, Postcondition: (1) Prints out the array in a format similar to the way Python outputs a list (2) If the array was 1, 4, 6, it would output [1, 4, 6] Without any newlines or spaces before and after the brackets (3) he numbers will output with fixed precision set to the passed precision value
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