9/10/2017

DCT1144 Programming Fundamentals LAB 11 Sept 2017

1. Design an algorithm and write a C++ program to find the perimeter and area of a rectangle. The perimeter and area of the rectangle are given by the following formulas:
    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 = "<    cout<<"\n Area of a rectangle = "<    system("PAUSE");
    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:

Cara download Installer windows 10 dalam format ISO

1. Jika anda bercadang untuk download windows 10 melalui website rasmi windows - pilihan untuk download dalam format ISO tidak di berikan.  ...