Professional Documents
Culture Documents
Laboratory Exercise
Name
Date
Section
1/21/2016
A2
Problem Statement:
1.) A circular racetrack is composed of 4 portions: concrete, mud, sand, and asphalt. The
racers car takes 18 seconds to cross the concrete, 23 seconds to cross the mud, 38
seconds to cross the sand, and 33 seconds to cross the asphalt. Create a C++ program
that would input a positive time value (in seconds) and output where in the track
Schumachers car is after that specified time. Assume that the race starts at the
beginning of the concrete. Moreover, the car can go around the track more than once.
2.) Create a C++ program that takes the lengths of three sides of a triangle as inputs and
display a message that tells whether the triangle is equilateral (three sides equal),
isosceles (two sides equal), or scalene (no sides equal).
3.) Create a C++ program that accepts numeric values (represented by X and Y) as point to
a rectangular coordinate system. Output a message that tells where the point lies.
Example:
X
>0
<0
<0
>0
0
>0
<0
0
0
Y
>0
>0
<0
<0
0
0
0
>0
<0
Message
1ST Quadrant
2ND Quadrant
3RD Quadrant
4TH Quadrant
Point of Origin
Positive X-axis
Negative X-axis
Positive Y-axis
Negative Y-axis
Criteria
1.)
2.)
3.)
4.)
5.)
6.)
7.)
8.)
9.)
10.)
Score
Total
_______________________
Engr. Cristina A. Pascua
5
5
20
5
5
20
5
5
20
10
100
_______________
Date
Name
Date
Section
File Name:
Answer Sheet:
1.)
C++ Program
#include <iostream>
using namespace std;
int main()
{
int s ;
cout<< "Input the current time in seconds" ;
cin>> s;
if (s-18 && s<=36)
cout<< "The car is in concrete.";
else if (s-41 && s>=82)
cout<< "The car is in mud.";
else if (s-79 && s>=158)
cout<< "The car is in sand.";
else if (s-121 && s>=242)
cout<< "The car is in asphault.";
system("pause");
return 0;
}
2.)
C++ Program
A2
#include <iostream>
using namespace std;
int main ()
{
int x1, x2, x3 ;
cout<< "Input 1st Side" << endl;
cin>> x1;
cout<< "Input 2nd Side" << endl;
cin>> x2;
cout<< "Input 3rd Side" << endl;
cin>> x3;
if (x1== x2 && x1 == x3)
cout<< "Equilateral Triangle " << endl;
system("pause");
return 0;
3.)
C++ Program
#include <iostream>
using namespace std;
int main ()
{
int x, y ;
cout<<"Input First integer" <<endl ;
cin>> x;
cout<<"Input Second integer" <<endl ;
cin>> y;
if (x>0 && y>0)
cout<<"1st Quadrant" <<endl ;
else if (x<0 && y>0)
cout<<"2nd Quadrant" <<endl ;
else if (x<0 && y<0)
cout<<"3rd Quadrant" <<endl ;
else if (x>0 && y<0)
cout<<"4th Quadrant" <<endl ;
else if( x==0 && y==0)
cout<<"Point of origin" <<endl ;
else if (x>0 && y==0)
cout<<"Positive X-axis" <<endl ;
else if (x<0 && y==0)
cout<<"Negative X-axis" <<endl ;
else if(x==0 && y>0)
cout<<"Positive Y-axis" <<endl ;
else if (x==0 && y<0)
cout<<"Negative Y-axis" <<endl ;
system("pause");
return 0;
}