Friday, 30 March 2012

Determine whether the wake is a square or rectangle!


 a.         a Problem Analysis : Input-Process-Output
     Case Example
Input
Process
Output
If you want to look up whether a square or rectangular



Enter the length and width



> Formula for area of ​​rectangle = p * l
> The formula circumference of a rectangle = 2 * (p + l)
> Formula square area = p * l
> Circumference formula square = p + p + l + l

Rectangular or square

b.     Program C++

#include <iostream>
#include <string>

using namespace std;

class bangun {
friend istream& operator>>(istream&, bangun&);
public:
void iya_bukan();
private:
int p,l;
              };

istream& operator>>(istream& in, bangun&masukan){
cout<<"Menentukanbangunpersegiataupersegipanjang\n";
cout<<"Masukan p : ";
         in>>masukan.p;
cout<<"Masukan l : ";
         in>>masukan.l;  
         }
void bangun::iya_bukan(){
      if (p==l)
cout<<"MerupakanBangunPersegi"<<endl;
     else
cout<<"MerupakanBangunPersegiPanjang"<<endl;
        }

main()
{
bangun x;
cin>>x;
x.iya_bukan();

   system ("Pause");
   return 0;


c.         Debugging and Testing

Debugging methods / Tested data
Correct / Runtime error / Logical error
Follow-up / Improvement
Masukan contoh panjang=22 dan lebar=22









persegi




0 comments:

Post a Comment

.

.

.

.
Design by BlogSpotDesign | Ngetik Dot Com