Flowchart:: Buscano, Jon Hermie A./Bsee/Ceit 04-401A/Engr. Dolly Cruz/March 31, 2008 Exer3-1 .CPP
Flowchart:: Buscano, Jon Hermie A./Bsee/Ceit 04-401A/Engr. Dolly Cruz/March 31, 2008 Exer3-1 .CPP
Flowchart:: Buscano, Jon Hermie A./Bsee/Ceit 04-401A/Engr. Dolly Cruz/March 31, 2008 Exer3-1 .CPP
Read room_number
Read enrolled
Read Capacity
empty_seats = capacity-enrolled
Print room_number
Program: #inlcude<iostream.h> //exer3-1 int main() { double room_no, enrolled, capacity, empty_seats; cout<<Enter room number\t\t:; cin>>room_no; cout<<Enter number of students enrolled:; cin>>enrolled; cout<<Enter room capacity\t\t:; cin>>capacity; cout<<\n; empty_seats = capacity-enrolled; cout<<Room\t;cout<<Capacity\t; cout<<Enrolled\t;cout<<Empty seats\t; cout<<Status\n; cout<<room_no<<\t;cout<<capacity<<\t\t; cout<<enrolled<<\t\t;cout<<empty_seats<<\t; if (empty_seats>0) cout<<open\n; else cout<<closed\n; return 0; }
Print enrolled
Print capacity
exer3-2.cpp
begin
number
Read number
if number<0
Print Negative
Print Positive
if number>=101
#inlcude<iostream.h> //exer3-2 int main() { double number; cout<<Enter number:; cin>number; if (number<0) cout<<negative\n; else cout<<positive\n; if (number>=101) cout<<Number read is greater than 100; else if (number==100) cout<,Number read is 100; else if (number>=11) cout<<Number read is greater than 10; else if (number==10) cout<<Number read is 10; else if (number>=0) cout<<Number read is less than 10; cout<<\n; return 0; }
if number==100
if number>=11
if number==10
if number>=0
Read a #include<iostream.h> #include<math.h> //exer3-3 int main() { double a, b, c, root1, root2; cout<<Enter value of \a\:; cin>>a; cout<<Enter value of \b\:; cin>>b; cout<<Enter value of \c\:; cin>>c; root1 = -b+(sqrt(b*b)-(4*a*c))/(2*a); root2 = -b-(sqrt(b*b)-(4*a*c))/(2*a); cout<<root1 = <<root1; cout<<\n; cout<<root2 = <<root2; cout<<\n; return 0; }
Read b
Read c
root1 = -b+b*b-4ac/2a
root2 = -b-b*b-4ac/2a
Print root1
Print root2
end
exer3-4.cpp begin
f1 f2 f3 #include<iostream.h> //exer3-4 int main() { double f1, f2, f3; cout<<enter 1st floating point number:; cin>f1; cout<Enter 2nd floating point number:; cin>>f2; cout<<Enter 3rd floating point number : ; cin>>f3; if ((f1>f2) && (f1>f3)) cout<<The largest number is :<<f1<<\n; else if ((f2>f3) && (f2>f1)) cout<The largest number is :<<f2<<\n; else if ((f3>f1) && (f3>f2)) cout<<The largest number is :<<f3<<\n; if ((f1<f2) && (f1<f3)) cout<< The smallest number is :<<f1<<\n; else if ((f2<f3) && (f2<f1)) cout<<The smallest number is :<<f2<<\n; else if ((f3<f1) && (f3<f2)) cout<<the smallest number is :<<f3<<\n; return 0; }
Read f1
Read f2
Read f3
if f2>f2&&f1>f3
if f2>ff3&&f2>f1
if f3>f1&&f3>f2
if f1<f2&&f1<f3
if f2<f3&f2<f1
if f3<f1&&f3<f2
end
Print root2
exer3-5.cpp begin #include<iostream.h> #define pi 3.1416 //exer3-5 int main() { char choice; double radius, circumference, area, diameter; cout<<Enter radius of a circle:; cin>>radius; cout<<Would you like to find:; cout<<c-circumference of a cirle\n<<\t\t\t; cout<<a-area of a circle\n<<\t\t\t; cout<<d-diameter of a circle\n; cout<<key in your answer within 5 seconds cin>>choice; cout<<\n; switch (choice) { case A:/*this has a common statement*/ case a : area = pi*radius*radius; cout<<The area of a circle is :<<area\n; break; case D: case d : diameter = 2*radius; cout<<The diameter of a circle is :<<diameter\n; break; case C: case c : circumference = 2*pi*radius\n; cout<<The circumference of a circle is: <<circumference\n; break; default:cout<<stupid man\n; } return 0; }
Print Enter radius of a circle: choice pi = 3.1416 radius diameter=0 area=0 circumference =0
Read radius
Read choice
if choice== c
circumference = 2*pi*radius
Print circumference
if choice== a
area = pi*radius*radius
Print area
if choice== d x end
diameter = 2*radius
Print diameter
exer3-6.cpp begin
hour min con_hour #include<iostream.h> //exer3-6 int main() { int hour, min, con_hour; cout<<Input time in a 24-hour notation:; cout<<note: key in five characters only.; cin>>hour; cout<<:; cout<<min; cout<<\n\n\n; switch (hour) x { case 01: case 02: case 03: case 04: case 05: case 06: case 07: case 08: case 09: case 10: case 11: case 12:cout<<The time is : <<hour<<:<<min<<am\n; break; case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24:con_hour = hour-12 cout<<The time is : <<con_hour<<:<<min<<pm\n; break; } return 0; }
if hour<=12
con_hour = hour-12
x end
-March 31, 2008 Buscano, Jon Hermie A. BSEE/CEIT 04-401A ENGR. DOLLY CRUZ