Vous êtes sur la page 1sur 5

# PROBLEM STATEMENT 1

/* PROBLEM STATEMENT 1:
Design and create a program that will
prompt the user to enter the number of
hours required to install a hardwood floor.
Display the number of complete eight-hour
work days required for the job, as well as
the remaining hours needed in the last day.
Compute and display the total cost of the
job at Php 350 per day plus Php 50 per hour
for any partial day. */
#include <iostream>
using namespace std;
int main ()
{ int TOTALcost, pay_350, pay_50,
COMPLETEDhr, REMAININGhr, hrs;
cout << " This program will able to enter
the number of hours required to install a
hardwood floor" << endl;

## cout << "Please enter the number of hours:";

cin >> hrs;
//FORMULAS
COMPLETEDhr = hours / 8;
REMAININGhr = hours % 8;
pay_350 = 350 * COMPLETEDhr;
pay_50 = 50 * REMAININGhr;
TOTALcost = pay_350 + pay_50;
cout << "Number of complete eight-hour work
day/s: " << COMPLETEDhr << " hour/s" << endl;
cout << "Number of remaining hour/s: "<<
REMAININGhr << " hour/s" << endl;
cout << "Total cost of the job is Php " <<
TOTALcost;
cout << endl;
cin.get ();
return 0;
}

PROBLEM STATEMENT 2
/* PROBLEM STATEMENT 2:
Design and create a program for a bank
that allows the user to enter
an amount of money in cents. Display the
number of whole peso the bank
will give the customer in exchange. */
#include <iostream>
using namespace std;
int main ()
{ int cent, peso;
cout << "BANK SERVICE" << endl;
cout << " Please enter the amount of
money in cents: ";
cin >> cent;

cout << "You entered an amount of " << cent << "
centavos." << endl;
//CENTAVOS TO PESOS FORMULA
peso = cent/100;
// Conversion of centavos to pesos (OUTPUT)
cout << "The number of whole peso the bank will
give in exchange is " << peso << " peso/s" << endl;
return 0;
}

PROBLEM STATEMENT 3
/* PROBLEM STATEMENT 3:
All years that are evenly divisible by 400
or are evenly divisible by four and not
evenly divisible by 100 are leap years.
For example, since 1600 is evenly
divisible by 400, the year 1600 was a leap
year. Similarly, since 1988 is evenly
divisible by four but not by 100, the year
1988 was also a leap year. Using this
information, write a C++ program that
accepts the year as user input, determine
if the year is a leap year, and displays an
appropriate message that tells the user if
the entered year is or not a leap year. */
#include <iostream>
using namespace std;
int main()
{ int year;

## cout << "IS IT A LEAP YEAR OR NOT? " << endl;

cout << "Please enter a year: ";
cin >> year;
/* Conditions to satisfy a leap year:
1. Years that are divisible by 4.
2. If it's divisible by 100, it isn't. BUT if its divisible
by 400, it is. */
if (year%4==0 && year&100!=0 || year&400==0)
cout << "The year, " << year << ", is a leap year!"<<
endl;
else
cout << "The year, " << year << ", is NOT a leap
year!" << endl;
return 0;
}

PROBLEM STATEMENT 4
/* PROBLEM STATEMENT 4:
Based on an automobile's model year and
weight the state of New Jersey determines the
car's weight class and registration fee using
the following schedule:
Using this information, write C++ program that
accepts the year and weight of
an automobile and determine and displays the
weight class and registration fee for the car. */
#include <iostream>
using namespace std;
int main ()
{ int year, lbs;
// This program will let you know the weight
class and registration for the automobile car
cout << "AUTOMOBILE's WEIGHT CLASS
& REGISTRATION FEE" << endl;

## if (year <= 1970)

{ if (lbs < 2700)
cout << "The weight class is 1 and the
registration fee is \$16.50" << endl;
else if (lbs >= 2700 && lbs <= 3800)
cout << "The weight class is 2 and the
registration fee is \$25.50" << endl;
else
cout << "The weight class is 3 and the
registration fee is \$46.50" << endl; }
else if (year >= 1971 && year <=1979)
{ if (lbs < 2700)
cout << "The weight class is 4 and the
registration fee is \$27.00" << endl;
else if (lbs >= 2700 && lbs <= 3800)
cout << "The weight class is 5 and the

## cout << "Please enter the automobile's model

year: ";
cin >> year;
cout << "Please enter the automobile's weight
in lbs: ";
cin >> lbs;
cout << endl;

## registration fee is \$30.50" << endl;

else
cout << "The weight class is 6 and the
registration fee is \$52.50" << endl; }
else
{ if (lbs < 3500)
cout << "The weight class is 7 and the
registration fee is \$19.50" << endl;
else
cout << "The weight class is 8 and the
registration fee is \$52.50" << endl; }
cin.get ();
cin.get ();
return 0;
}

PROBLEM STATEMENT 5
/* PROBLEM STATEMENT 5:
The program will ask for a number. Then will
display the odd numbers on that number. Then on
the next line will show the even numbers from
the number we have input. Then add up all even
numbers and multiply all the odd numbers.

## cout << INPUT VALIDATION: << endl;

cout << " Input a Number: ";
cin >> number;

Input Validation:
Input an integer:

{ if (i%2==0)
{ cout<< i <<" ";
sum_even+=i; } }
cout << endl;

Sample Run:
Input a number 15
Odd Number: 1 3 5 7 9 11 13 15
Even Number: 4 6 8 10 12 14
Sum of Even numbers: 56
Product of Odd Numbers: 2027025 */
#include <iostream>
using namespace std;
int main ()
{ int number sum_even=0,product_odd=1;

## cout<<"Even Number: ";

for (int i=1; i<=number; i++)

## cout<<"Odd Numbers :";

for (i=1; i<=number; i++)
{if (i%2!=0)
{ cout<< I <<" ";
product_odd*=i; } }
cout << endl;
cout<< " Sum of Even Numbers: "<<
sum_even << endl;
cout<< " Product of Odd Numbers: " <<
product_odd << endl;

return 0;
}

PROBLEM STATEMENT 6
/* PROBLEM STATEMENT 6:
The Fibonacci Sequence is a sequence of
numbers that are obtained by adding the
last two numbers in the sequence to get
the next one. Usually, the first two
numbers in the sequence are 0 and 1. This
leads to the sequence: 0, 1, 1, 2, 3, 5, 8,
13, 21, 24, 35, 55. As you can see, each
term in the sequence is equal to the sum
create a program that will generate a
Fibonacci Type Sequence of length N,
given the two first numbers in the
sequence A and B.
Input:
N, an integer, the length of the output
sequence required (0 <= N <= 100), A
and B, both integers, the first and second
items in the sequence (0<=A<=100;
0<=B<=100)
Output:
N, integers, separated by spaces of the
Fibonacci Type Sequence beginning with
A and B */
#include <iostream>
using namespace std;
int main ()
{ int N, c, first = 0, second = 1, next;
cout << "FIBONACCI SEQUENCE" <<
endl;
cout << " Input length: ";
cin >> N; // N, an integer, the length
cout << "A: " << first << endl;
cout << "B: " << second << endl;

/* PROBLEM STATEMENT 6:
Using loop, write a program that will ask the user to
enter a character for left or right. Then, the user will
enter a number. The program should generate a ladder
of x wherein the level depends on the number entered
and the character should dictate whether it faces right
or left.
SAMPLE:
Character is
Character is
Character is l
r
r
Number is 5
Number is 3
Number is 4
X
X
X
XX
XX
XX
XXX
XXX
XXX
XXXX
XXXX
XXXXX
*/
#include <iostream>
#include <string>
using namespace std;
int main( )
{ char c;
int number, n, i, j, k;
cout << "Character is ";
cin >> c;
cout << "Number is ";
cin >> number;
n = number - 1;
for (i = 0; i < num; ++i)
{ if (toupper(c) == 'L')
{ for (k = 0; k < n; ++k)
{ cout << " "; }
--n; }
if (toupper(c) == 'L' || toupper(c) == 'R')

## cout << "First " << N << " terms of

Fibonacci Series are: " << endl;
for (c = 0; c < N; c++)
{ if (c <= 1)
next = c;
else
{ next = first + second;
first = second;
second = next; }
cout << " " << next; }
return 0;
}

{ cout << "X"; }
cout << endl;
}}
return 0;
}