0% found this document useful (0 votes)
73 views

Assignment Csc402

The document describes a C++ program to calculate the area of different geometric objects. It includes (a) pseudocode describing the input, process, and output of calculating areas of a rectangle, triangle and circle, (b) pseudocode of the full program, and (c) the C++ code implementing the program. The program prompts the user to input dimensions, calculates the individual areas of the rectangle, triangle and circle using formulas, calculates the total area, and displays the results.

Uploaded by

pandamalaya10
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views

Assignment Csc402

The document describes a C++ program to calculate the area of different geometric objects. It includes (a) pseudocode describing the input, process, and output of calculating areas of a rectangle, triangle and circle, (b) pseudocode of the full program, and (c) the C++ code implementing the program. The program prompts the user to input dimensions, calculates the individual areas of the rectangle, triangle and circle using formulas, calculates the total area, and displays the results.

Uploaded by

pandamalaya10
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

(a)

Input Process Output

Length, Area_rec = length x width Area_rec

width, Area_tri = 0.5 x length x height Area_tri,

height radius = width / 2 Area_cir,

Area_cir = PI x pow(radius,2) Area_obj

Area_obj = Area_rec + Area_tri + Area_cir

(b)
START
Display "Please enter the length of rectangle in meter: "
Display "Please enter the width of rectangle in meter: "
Display "Please enter the heigth of triangle in meter: "
Read length, width, height
const float PI=3.142
Area_rec = length * width
Area_tri = 0.5 * length * height
radius = width / 2
Area_cir = PI * pow(radius,2)
Area_obj = Area_rec + Area_tri + Area_cir
Display “The area of rectangle is” , Area_rec
Display “The area of triangle is” , Area_tri,
Display “The area of circle is” , Area_cir,
Display “The area of objects is” , Area_obj
END

(c)
//NAME : AIN NUR BALQIS BINTI HAMIZUL
//DATE : 2/11/2023
//PROGRAM TITLE : Calculate area of the objects

#include <iostream>
using namespace std;

int main ()
{
//Declare in data type double
double length,width,heigth,radius,area_rec,area_tri,area_cir,area_obj;
//Initiallize constant in data type float
const float PI = 3.142;

//user friendly message to prompt user to input data


cout<<"Please enter the length of rectangle in meter: ";
cin>> length;
cout<<"Please enter the width of rectangle in meter: ";
cin>> width;
cout<<"Please enter the height of triangle in meter: ";
cin>> heigth;

//Calculate the area


area_rec = length * width;
radius = width / 2;
area_tri = 0.5 * length * heigth;
area_cir = PI * radius * radius;
area_obj = area_tri + area_cir + area_obj;

//Display appropriate message with the output value


cout << endl << "The area of rectangle = " << area_rec << " square meter" << endl;
cout << "The area of triangle = " << area_tri << " square meter" << endl;
cout << "The area of circle = " << area_cir << " square meter" << endl << endl;
cout << "The area of the objects = " << area_obj << " square meter" << endl;

return 0;
}
(a)
Input Process Output

RM Convert from Malaysian Ringgit to Japanese Yen and Yen,


Jordanian Dinar. Dinar
Yen = RM * 31.35
Dinar = RM * 0.15

(b)
(c)
//NAME : AIN NUR BALQIS BINTI HAMIZUL
//DATE : 2/11/2023
//PROGRAM TITLE : Covert from Malaysian Ringgit (RM) to japanese Yen and to
Jordanian Dinar

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
//Declare in data type double
double RM,Yen,Dinar;

//Prompt user to enter the value of RM


cout << "Enter amount of RM that you want to convert : RM";
cin >> RM; //Input RM

Yen = RM * 31.35; //Covert RM to Yen


Dinar = RM * 0.15; //Convert RM to Dinar

//Set to 2 decimal places


cout<<setprecision(2)<<fixed;

//Display appropriate message with the output value


cout << endl << "The amount of Japanese Yen is : " << Yen << " Yen" << endl;
cout << "The amount of Jordanian Dinar is : " << Dinar << " Dinar" << endl;

return 0;
}
(a)
Input Process Output

num Check if num > 0 Message “positive” or


Display “positive” “negative” or
“zero”
Check if num < 0
Display “Negative”

Else display “Zero”

(b)
START
Display “Enter a number”
Read num
IF num > 0 THEN
Display “positive”
ELSE IF num < 0 THEN
Display “negative”
ELSE
Display “zero”
END IF
END IF
END
Input Process Output

minute Convert the entered number of minutes into Display hour and min
hours and minutes.
hour = minute / 60
min = minute % 60

(a)

(b)
START
Display "Enter numeric value for minute : "
Read minute
hour = minute / 60
min = minute % 60
Display "The answer is " , hour , “hours” , min , “minutes”
END
(c)
//NAME : AIN NUR BALQIS BINTI HAMIZUL
//DATE : 2/11/2023
//PROGRAM TITLE : Convert entered number of minutes into hour and minute

#include <iostream>
using namespace std;

int main()
{
int minute,min,hour; //Declare in data type double

//Prompt user to enter the numeric for minute


cout << "Enter numeric value for minute : ";
cin >> minute; //Input minute

//Convert the input into hour and minute


hour = minute / 60;
min = minute % 60;

//Display appropriate message with the output value


cout << "The answer is " << hour << " hours " << min << " minutes";

return 0;
}

You might also like