
Watch this post - more to come!
- Write a program which contains overloaded functions for computing area of a shape. The shapes which you must handle are circle, square, rectangle, and triangle.
You must write two functions:
double calculateArea(double d, Shape s)
double calculateArea(double d, double e,
Shape s)
You must also declare an enumeration, Shape with the constants:
CIRCLE
SQUARE
RECTANGLE
TRIANGLE
Use 3.14 as the value for PI. The pow function is in the cmath library.
The first calculateArea function must be able to compute the area circles and squares, based on the Shape value sent to it. Similarly, the second function must be able to compute the area of rectangles and triangles. Your main should test both functions for both possible shapes. Your functions must trap invalid shapes and negative distance input, returning 0 for the area in those cases.Sample OutputHere is a screenshot of my code running. - Write a program that creates a ten element array and populates it with random numbers. Print the array. Locate the position in the array of the largest element and the smallest element and display both their locations and their values. You must also sum all the values in the array and print the sum and the average element value.
You must write five functions:
void populateList(int list[SIZE])
void printList(int list[SIZE])
int locateMin(int list[SIZE])
int locateMax(int list[SIZE])
int sumElements(int list[SIZE])Sample OutputHere is a screenshot of my code running. - Write a program containing a function which counts up the number of a given character in a string. This function must be case-sensitive.
You must write three functions:
string getSentence()
char getCharacter()
int countItem(string s, char c)Sample OutputHere is a screenshot of my code running. - Write a program containing a function which counts up the number of punctuation marks in a string. Note: there is a helpful c++ function called ispunct.
You must write two functions:
string getSentence()
int countPunctuation(string s)Sample OutputHere is a screenshot of my code running. - Write a program containing a function which counts up the number of numerals in a string. Note: there is a helpful c++ function called isdigit.
You must write two functions:
string getSentence()
int countDigits(string s)Sample OutputHere is a screenshot of my code running. - Write a program containing a function which counts up the number of uppercase and lowercase characters in a string. Note: there are helpful c++ functions called isupper and islower.
You must write two functions:
string getSentence()
int countAlphas(string s,
int &uppers, int &lowers)Sample OutputHere is a screenshot of my code running. - Write a program containing a function which counts up the number of spaces in a string. Note: there is a helpful c++ function called isspace.
You must write two functions:
string getSentence()
int countSpaces(string s)Sample OutputHere is a screenshot of my code running. - Write a program to solve quadratic equations. The discriminant is defined as
If the discriminant is positive, the equation has two real roots; if it is exactly zero, the equation has one real root; if negative, there are no real roots.
You must write five functions:
void getCoefficients(int &a,
int &b, int &c)
int calculateDiscriminant(int a,
int b, int c)
void displayRoots(int a, int b, int d)
double getRoot1(int a, int b, int d)
double getRoot2(int a, int b, int d)Sample OutputHere is a screenshot of my code running. - Write a program that requests vector size from user. Create and populate the vector with random numbers in the range [0-99]. Print the vector's elements. Sort the vector. Print the elements again. Calculate and display the sum of all elements and average element value.
You must write four functions:
void populateVector(vector&list)
void sumVector(vector&list, int &sum)
void printVector(vector&list, string leader)
void displayVectorStats(vector&list) Sample OutputHere is a screenshot of my code running.

Calculate Areas output

Max and Min output

Count Item output

Count Punctuation output

Count Digits output

Count Alphas output

Count Spaces output

Quadratic Equation output

Analyze Vector output