0% found this document useful (0 votes)
48 views

Es 123 Programming Languages 1 Laboratory Exercises: FILENAME: Surname-Inflation

The document contains source code for 3 C++ programs: 1) A future cost estimator that calculates the inflated cost of an item over a number of years given the original cost, inflation rate, and number of years. 2) An installment payment calculator that shows the monthly interest and principal payments over the life of a loan. 3) A program that calculates how many candy bars can be purchased with a given amount of money using a bulk discount where 7 candy bars costs 1 less than buying them individually.

Uploaded by

Mary Joy Delgado
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Es 123 Programming Languages 1 Laboratory Exercises: FILENAME: Surname-Inflation

The document contains source code for 3 C++ programs: 1) A future cost estimator that calculates the inflated cost of an item over a number of years given the original cost, inflation rate, and number of years. 2) An installment payment calculator that shows the monthly interest and principal payments over the life of a loan. 3) A program that calculates how many candy bars can be purchased with a given amount of money using a bulk discount where 7 candy bars costs 1 less than buying them individually.

Uploaded by

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

ES 123 PROGRAMMING LANGUAGES 1

LABORATORY EXERCISES

FILENAME: surname-inflation

Source Code:

#include <iostream>
using namespace std;

int main()
{
float cost, year;
float n;
float rate;
char x;

cout << "This is the Future Cost Estimator.\n";


cout << "Each entry is to be followed by a <return>\n\n\n";

cout << "Enter the cost of the item in peso: ";


cin >> cost;

cout << "\n\n";

cout << "Enter the inflation rate as a percentage \nsuch as 5.6 for 5.6 percent: ";
cin >> rate;

cout << "\n\nEnter an integral number of years to the time\n”;


cout << ”when you want the estimate: ";
cin >> year;

cout << "\n\n”;

for (n=1; n <= year; n++)


{
cost = (1 + (rate/100))*cost;

cout << "The inflated cost for year "<<n<<" is Php " << cost<<"\n";;
}
return 0;
}
Sample Output:
FILENAME: surname-installment

Source Code:

#include <iostream>
using namespace std;

int main()
{
double m = 0;
double payment = 50;
double i;
double num_pay, last_int, last_pay;
double p = 1000;
double r = 0.18;
double less;

cout << "MONTHS\t\tINTEREST\t\tPRINCIPAL\n";

while (principal > payment)


{
m = months + 1;
i = p *( r / 12 );
less = payment - i;
p = p - less;

cout.setf(ios::fixed);
cout.precision(0);
cout << m;

cout.setf(ios::fixed);
cout.precision(2);
cout << "\t\t" << i << "\t\t\t" << p << "\n";
}

cout << endl;

num_pay = m+1;
last_int = p *( r / 12 );
last_pay = last_int + p;

cout.setf(ios::fixed);
cout.precision(0);
cout << "number of payments: " << num_pay<<" ";

cout.setf(ios::fixed);
cout.precision(2);
cout << "last month interest: " << last_int << " ";
cout << "last payment: " << last_pay << " ";

return 0;
}
Sample Output:
FILENAME: surname-chocolates

Sample Output:

#include <iostream>
using namespace std;

int main()
{
int php, c, b, coup, l;

cout << "Enter the number of peso you have to spend: \n";
cin >> php;
c = php;
coup = c;
l = coup;
while (l>=7)
{
l = coup % 7;
b = coup / 7;
coup = l + b;
l = coup;

c = c + b;

}
cout << "\nYou can get " << c << " candy bars with ";
cout << l;
cout << " coupons leftover."<<endl;
return 0;
}

Sample Output:

You might also like