Calculate the area of a rectangle.
- Utilize at least three functions, “Get Input” – “Calculation” – “Show Output”
- The “Get Input” function must use call-by-reference parameters to gather data
- The program must ask the user if they would like to run it again
This is a C++ Project using call by reference. If possible please make it as simple as possible as i'm already very confused the way it is.
Dear Student ,
As per the requirement submitted above , kindly find the below solution.
Here a new C++ program with name "main.cpp" is created, which contains following code.
main.cpp :
//c++ program to calculate area of rectangle
#include <iostream> //header files
using namespace std;
//function prototype
void GetInput(int &l,int &b);
double Calculation(int l,int b);
void ShowOutput(int l,int b,double area);
int main() //main method
{
//declaring variables
int l,b;
double area;
char choice;//variable used to store user choice
bool flag=true;//variable to store user choice
while(flag){
//calling function to take input from user
GetInput(l,b);
area=Calculation(l,b);//calling funtion to calculate area
ShowOutput(l,b,area);//calling function to print area
//asking user his choice
cout<<"Would like to run it again (y/n): ";
cin>>choice;//reading choice
//checking choice
if(choice=='n')
{
flag=false;//set flag to false to break the loop
}
}
return 0;
}
//function to get input from user
void GetInput(int &l,int &b){
//asking user to enter length
cout<<"Enter Length :";
cin>>l;//reading length
//asking user to enter breadth
cout<<"Enter Breadth :";
cin>>b;//reading breadth
}
//function to calculate area of rectangle
double Calculation(int l,int b){
return l*b;//return area of rectangle
}
//function to show area
void ShowOutput(int l,int b,double area){
//show area
cout<<"Area of rectangle with length "<<l<<" and
breadth "<<b<<" is "<<area<<endl;
}
======================================================
Output : Compile and Run above program to get the screen as shown below
Screen 1 :main.cpp

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.
Calculate the area of a rectangle. - Utilize at least three functions, “Get Input” – “Calculation” –...
Python Programming Write a program that reads the dimension of a rectangle and prints its area. The program must handle errors such invalid input. If it encounters an error, it should ask the user to reenter the input. Sample run: Enter height:abc abc is not a vaid input. Try again. Enter height:10 Enter width:hello hello is not a vaid input. Try again. Enter width:world world is not a vaid input. Try again. Enter width:xyz xyz is not a vaid input....
Problem: Given information about a circle, rectangle and a triangle, calculate the area of the shape from the information supplied. Write pseudocode to solve this problem and write a Python program that asks the user to input the required information for a shape and then calculates the area of the shape. Geometry Calculator 1. Calculate the Area of a Circle 2. Calculate the Area of a Rectangle 3. Calculate the Area of a Triangle 4. Quit Enter your choice (1...
Java Using NetBean Design a math method rectArea to calculate rectangle area = width * height. Your main program will get width and height from user and call rectArea for calculation and then the main program will show the final result.
Complete the Rectangle Program Using the code given in rectangle.cpp, implement the functions that are called in the main function to complete the program. You must not change any of the existing code in the file. You can only add functions and comments to the code. Here’s a sample run of how the program should behave: Enter rectangle length: -1 ← invalid value, ask user to re-enter Enter rectangle length: -2 ← invalid value Enter rectangle length: 0 ← invalid...
Python 3: Please follow the respective rubric
for the following function definition.
Rubric:
Rectangle Shape You should implement the following functions to print a rectangle shape. • print_rectangle(length, width, fillChar, hollow). This function will use draw_shape_line() function to print a rectangle shape with the given length and width, If the hollow is true, the shape will be hollow rectangle, otherwise a filled rectangle. This function must not interact with the user. For example, the call print_rectangle(5, 10, '*', False) should...
C++ Pr ogramming (CSC-115) Functions (pass by Reference) Programming project Using FUNCTIONS, write a C++ program that calculates the Area of a cirele, a square and a rectangle. Your program must prompt the user to select which area is to be calculated. Document your program. Apply the do while loop to repeat the program Apply the while loop for input validation. Apply the switch statements or the if/ else if statement to prompt the user for the area's selection. Based...
/4 Question An area of square, drea ofa rectangle and triangle can be calculated by using the given formula: sqareaa (renww value from the functioi area is reciabgle-(retrn valwe from the function is area int) ceouatre -D-(return value fromtheneion e s double t and s s formula must be use when the values for the sides of the triangle are whether you want to calculate the area of square or a. b and c are the sides of the triangle...
Lab 7: Void and Value-Returning Functions Lab 7: Void and Value-returning functions Due date: 11/6/19 Problem: Write a C++ program that calculates the areas of a rectangle and of an ellipse. Area = base * height Area = π * radius a * radius b Note: all images extracted from http://www.mathsisfun.com/area-calculation-tool.html ------------------------------------------------------------------------------------------------------------------------ Your task: implement in C++ the algorithm solution shown below. ------------------------------------------------------------------------------------------------------------------------ Part A (79...
WITHOUT FUNCTIONS. Could anyone help me solve this problem not using the function ? Thanks a lot. Pig Dice Game Pig is a simple two player dice game, played with one die. The first player to reach or surpass 50 is the winner. Each player takes a turn rolling the dice. They add to the pot with each roll, having to decide to roll again and increase the pot, or cash out. The risk being they could lose the amount...
You will create a Grade Program that will calculate students’ weighted averages. You are going to have the user enter lab grades, test grades, and project grades. You will then display a grade report of each individual average along with their overall average and letter grade. Ask the user to enter their lab grades. Call the averageGrade function that will allow the user to enter their grades and calculate their average. averageGrade Function: This will pass the average back to...