Flowchart:: Buscano, Jon Hermie A./Bsee/Ceit 04-401A/Engr. Dolly Cruz/March 31, 2008 Exer3-1 .CPP

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 6

BUSCANO, JON HERMIE A./BSEE/CEIT 04-401A/ENGR. DOLLY CRUZ/MARCH 31, 2008 exer3-1 .

cpp Flowchart: begin

room_number enrolled capacity empty_seats

Print "Enter Room no.:

Read room_number

Print Enter no. of students enrolled:

Read enrolled

Print Enter capacity:

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

Print empty seats

Y If empty_seats>0 N Print Closed" x end Print Open" x

exer3-2.cpp

begin

number

Print Enter Number:

Read number

if number<0

Print Negative

Print Positive

if number>=101

Print Number read is greater than 100

#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

Print Number read is 100 x

if number>=11

Print Number read is greater than 10

if number==10

Print Number read is 10

if number>=0

Print Number read is less than 10 x

end exer3-3.cpp begin

abc root1 root2

Print Enter value of a:

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; }

Print Enter value of b:

Read b

Print Enter value of c:

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; }

Print Enter 1st floating point number:

Read f1

Print Enter 2nd floating point number:

Read f2

Print Enter 3rd floating point number

Read f3

if f2>f2&&f1>f3

Print The largest number is f1

if f2>ff3&&f2>f1

Print The largest number is f2

if f3>f1&&f3>f2

Print The largest number is f3

if f1<f2&&f1<f3

Print The smallest number is f1

if f2<f3&f2<f1

Print The smallest number is f2

if f3<f1&&f3<f2

Print The smallest number is f3 x

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

Print Would you like to find: c-circumference a-area d-diameter

Print key in your answer w/n 5 seconds

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; }

Print Input time in a 24hour notation:

Read hour, min

if hour<=12

Print The time is: Print hour, min Print am

con_hour = hour-12

Print The time is : Print con_hour Print pm

x end

-March 31, 2008 Buscano, Jon Hermie A. BSEE/CEIT 04-401A ENGR. DOLLY CRUZ

You might also like