/* 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;
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;
cout << "Please enter the automobile's model year: "; cin >> year;
cout << "Please enter the automobile's weight in lbs: "; cin >> lbs; cout << 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 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.
Input Validation: Input an integer:
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;
/* 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 of the two terms before it. Your task is to 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; 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; }
/* 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 r Number is 3
X XX XXX
Character is r Number is 4
X XX XXX XXXX
Character is l Number is 5
X XX XXX 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') { for (j = 0; j < i + 1; ++j) { cout << "X"; } cout << endl; } }
return 0; }
CS10L / B13 & B6
Engr. Cheryl Isip 1st take Room:SW302 Day: Saturday Time: 7:30am -12:00nn 2nd take Room:SW408 Day: Monday Time: 12:30nn - 4:30pm Course Description: A laboratory course to accompany CS10.
Format of the Project :)
FEEDBACK...
Di porket alam mo na kung paano mag C++, papasa ka na. Di ko aakalaing babagsak ako dito nung 3rd term, lahat ng subjects ko ang tataas. Walang 3.00 meron nga lang 5.00. Nasaktan ako nung nakakuha ako 5.00 dito, seryoso. Pinagpuyatan ko kaya to. HAHAHA