perimeter = 2 * (length + width)
area = length * width
Algorithm
1. Get length of the rectangle
2. Get width of the rectangle
3. Find the perimeter using the following equation:
perimeter = 2 * (length + width)
4. Find the area using the following equation:
area = length * width
5. Print perimeter and area
C++ Program
#include
#include
using namespace std;
int main(int argc, char *argv[])
{
int length, width, Perimeter, Area;
cout<<" Please enter length and width of a rectangle \n";
cin>>length;
cin>>width;
Perimeter = 2* (length + width);
Area = length * width;
cout<<"Perimeter of a rectangle = "<
return EXIT_SUCCESS;
}
2. Design an algorithm and write a C++ program that reads a Fahrenheit degree in double, then converts it to Celsius and displays the result in a message dialog box. The formula for the conversion is as follows:
celsius = (5/9) * (fahrenheit - 32)
3. Design an algorithm and write a C++ program that calculates the sales tax and the price of an item sold in a particular state State’s portion of the sales tax is 4% City’s portion of the sales tax is 1.5% If the item is a luxury item, then there is a 10% luxury tax.
4. Design an algorithm and write a C++ program that input two integers and find the largest.
No comments:
Post a Comment