NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

/*Program Name: Homework#6 Rectangle Area.cpp
Programmer: Caleb Cohen
Date: 4/2/17
Version: 1.3
Description: Rectangle Area

Write a C++ program to get the user data for a rectangle and to calculate area of the rectangle. Your job is to complete the program. When it is complete, the program will ask the user to enter the width and length of a rectangle and then display the rectangle’s area. The program calls the following functions, which have not been written:
• getLength – This function should ask the user to enter the rectangle’s length and then return that value as a double .
• getWidth – This function should ask the user to enter the rectangle’s width and then return that value as a double .
• getArea – This function should accept the rectangle’s length and width as arguments and return the rectangle’s area. The area is calculated by multiplying the length by the width.
• displayData – This function should accept the rectangle’s length, width, and area as arguments and display them in an appropriate message on the screen.
Overload getArea function to calculate area of a rectangle and a circle. You can use getWidth function to get the side of a square and radius of a circle.*/

#include <iostream>
using namespace std;

//Setting up functions
double getLength();
double getWidth();
void displayData(double, double, double, double);
double getArea(double, double);
double getArea(double);

//Int main
int main(int a, int b)
{
//Defining variables
double length;
double width;
double area;
double area2;

//Functions setup
length = getLength();
width = getWidth();
area = getArea(length, width);
area2 = getArea(width);
displayData(length, width, area, area2);

//End Main
return 0;
}

//Get length functions
double getLength()
{
double Length;

cout << "Enter the length: ";
cin >> Length;

return Length;
}

//Get width function
double getWidth()
{
double Width;

cout << "Enter the width: ";
cin >> Width;

return Width;
}

//Display function
void displayData(double length, double width, double area, double area2)
{
cout << "nRectangle's Width: " << width << endl;
cout << "Rectangle's Length: " << length << endl;
cout << "Rectangle's Area: " << area << endl;
cout << "Circle's Area: " << area2 << endl << endl;
}

//Get area function (rectangle)
double getArea(double length, double width)
{
return length * width;
}

//Get area function (cirlce)
double getArea(double width)
{
return width * width * 3.14;
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.