0% found this document useful (0 votes)
168 views5 pages

LE2 Viado

The document contains a laboratory exercise with 3 programming problems. Problem 1 asks to create a program that takes a time in seconds and outputs where in a racetrack the car is located. Problem 2 asks to create a program that determines if a triangle is equilateral, isosceles, or scalene based on side lengths. Problem 3 asks to create a program that determines the quadrant or axis of a coordinate point based on x and y values. The document provides the expected C++ code solutions to each problem.

Uploaded by

Russell Viado
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
168 views5 pages

LE2 Viado

The document contains a laboratory exercise with 3 programming problems. Problem 1 asks to create a program that takes a time in seconds and outputs where in a racetrack the car is located. Problem 2 asks to create a program that determines if a triangle is equilateral, isosceles, or scalene based on side lengths. Problem 3 asks to create a program that determines the quadrant or axis of a coordinate point based on x and y values. The document provides the expected C++ code solutions to each problem.

Uploaded by

Russell Viado
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

CS10-1L Computer Fundamentals and Programming Laboratory

2 (Selection/Conditional Program Structure)

Laboratory Exercise

Name

VIADO, EMMANUEL RUSSELL P.

Date
Section

1/21/2016
A2

File Name: LE2_Surname.doc


To be uploaded in blackboard

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

Laboratory Exercise Score Sheet

Criteria
1.)
2.)
3.)
4.)
5.)
6.)
7.)
8.)
9.)
10.)

Score

Proper Indention of C++ program for number 1


Intelligent/Descriptive naming of variables for number 1

Correct logic for problem number 1


Proper Indention of C++ program for number 2
Intelligent/Descriptive naming of variables for number 2
Correct logic for problem number 2

Proper Indention of C++ program for number 3


Intelligent/Descriptive naming of variables for number 3

Correct logic for problem 3


Exercise finished/submitted within time-frame

Total

_______________________
Engr. Cristina A. Pascua

5
5
20
5
5
20
5
5
20
10
100

_______________
Date

CS10-1L Computer Fundamentals and Programming Laboratory


Laboratory Exercise

Name

2 (Selection/Conditional Program Structure)

VIADO, EMMANUEL RUSSELL


P.

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;

if (x1 == x3 && x1 != x2)


cout << "Isosceles Triangle"<< endl;
if (x2 == x3 && x2 != x1)
cout << "Isosceles Triangle" << endl;
if (x2 == x1 && x2 != x3)
cout << "Isosceles Triangle" << endl;
if (x1 != x2 && x1 != x3)
cout << "Scalene 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;
}

You might also like