c++ Please help! i keep getting an error message. I think my main problem is not understanding the circle calculations function and how both the area and the circumference is returned from the function. I know & needs to be used, but I am unsure how to use it.


#include <iostream>
using namespace std;
const double PI = 3.14159;
float getValidInput() {
float r;
cout << "Enter -1 for radius to exit." << endl;
cout << "Enter the radius: ";
cin >> r;
while(r != -1 && r < 0) {
cout << "invalid radius entered." << endl;
cout << "Try again. Enter the radius: ";
cin >> r;
}
return r;
}
void circleCalculations(float r, float &circ, float &area) {
area = PI * r * r;
circ = 2 * PI * r;
}
void printResults(float r, float circ, float area) {
cout << "Radius: " << r << endl;
cout << "Circumference: " << circ << endl;
cout << "Area: " << area << endl << endl;
}
int main() {
cout.setf(ios::fixed);
cout.precision(1);
float circ, area;
float r = getValidInput();
while(r != -1) {
circleCalculations(r, circ, area);
printResults(r, circ, area);
r = getValidInput();
}
}
************************************************** Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.
Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.
c++ Please help! i keep getting an error message. I think my main problem is not...
Keep getting this error message when trying to compile in main1.cpp. Need help figuring out how to make it compile. Thank you for your time. Error Message: main.cpp:(.text+0x13): undefined reference to `circle::circle()' main.cpp:(.text+0x32): undefined reference to `circle::circle(double)' main.cpp:(.text+0x3e): undefined reference to `circle::getArea() const' main.cpp:(.text+0x53): undefined reference to `circle::getRadius() const' main.cpp:(.text+0xb3): undefined reference to `circle::getArea() const' main.cpp:(.text+0xc8): undefined reference to `circle::getRadius() const' main.cpp:(.text+0x157): undefined reference to `circle::setRadius(double)' main.cpp:(.text+0x163): undefined reference to `circle::getArea() const' main.cpp:(.text+0x178): undefined reference to `circle::getRadius() const' main.cpp:(.text+0x207): undefined...
Please add //comments to the header file below. #ifndef CIRCLE_H_INCLUDED #define CIRCLE_H_INCLUDED #include <iostream> using namespace std; class Circle { private: double radius; // declaration of public methods in header file public: Circle() { // default value radius = 1; } void input() { cout << "Enter radius: "; cin >> radius; } void print() { double PI = 3.14159; double area = PI * radius * radius; double circumference = 2 * PI * radius; cout << "Circle with...
C++ programming question will upvote
A) One of the problems that have been discussed in the class is to write a simple C++ program to determine the area and circumference of a circle of a given radius. In this lab you will be rewriting the program again but this time you will be writing some functions to take care of the user input and math. Specifically, your main function should look like the following int main //the radius of the...
PLEASE TYPE OUT IN TEXT (please no pdf or writing) C++ CODE Consider the following program in which the statements are in the incorrect order. Rearrange the statements in the following order so that the program prompts the user to input: The height of the base of a cylinder The radius of the base of a cylinder The program then outputs (in order): The volume of the cylinder. The surface area of the cylinder Format the output to two decimal...
A) One of the problems that have been discussed in the class is to write a simple C++ program to determine the area and circumference of a circle of a given radius. In this lab you will be rewriting the program again but this time you will be writing some functions to take care of the user input and math. Specifically, your main function should look like the following: int main() { double radius; double area; double circumference; //the radius...
Consider the following program in which the statements are in the incorrect order. Rearrange the statements so that the program prompts the user to input the height and the radius of the base of a cylinder and outputs the volume and surface area of the cylinder. Formant the output to two decimal places. #include <iomanip> #include <cmath> int main () {} double height; cout << ”Volume of the cylinder = “ <<PI * pow(radius, 2.0) * height << endl; cout...
in c++ Finish the methods in the following code. DO NOT CHANGE THE MAIN METHOD. The instructions for each method are in a comment in the template. DO NOT CHANGE THE MAIN METHOD!!!! #include <iostream> #include <string> using namespace std; // prototypes int main() { int answer = 0; int value1 = 0; int value2 = 0; double average = 0; string string1 = ""; int numberVowels = 0; int numberNonVowels = 0; cout << "Enter string1: "; getline(cin, string1);...
How do I get this code to output The monthly payment is too low resulting in the loan amount not being able to be repaid, if the monthly payment is not higher than the interest rate. Right now I cant get it to say that. #include <iostream> using namespace std; int main() { double monthlyPayment; double remainingBalance; double interestRate; int month = 1; cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); cout << "Enter loan amount: $";...
The statement in the following program is in the incorrect order. Rearrange the statements so that they prompt the user to input the shape type (rectangle, circle, or cylinder) and the appropriate dimension of the shape. The program then outputs the following information about the shape: For a rectangle, it outputs the area and perimeter, for a circle, it outputs the area and circumference; and for a cylinder, it output the volume and surface area. After rearranging the statements, your...
My if/else statement wont run the program that I am calling. The menu prints but once I select a number the menu just reprints, the function called wont run. What can I do to fix this probelm? #include <iostream> #include "miltime.h" #include "time.h" #include "productionworker.h" #include "employee.h" #include "numdays.h" #include "circle.h" using namespace std; int main() { int select=1; while (select>0) { cout << "Option 1:Circle Class\n"<< endl; cout << "Option 2:NumDay Class\n" << endl; cout <<"Option 3:Employee and Production...