Es 123 Programming Languages 1 Laboratory Exercises: FILENAME: Surname-Inflation
Es 123 Programming Languages 1 Laboratory Exercises: FILENAME: Surname-Inflation
LABORATORY EXERCISES
FILENAME: surname-inflation
Source Code:
#include <iostream>
using namespace std;
int main()
{
float cost, year;
float n;
float rate;
char x;
cout << "Enter the inflation rate as a percentage \nsuch as 5.6 for 5.6 percent: ";
cin >> rate;
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.setf(ios::fixed);
cout.precision(0);
cout << m;
cout.setf(ios::fixed);
cout.precision(2);
cout << "\t\t" << i << "\t\t\t" << p << "\n";
}
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: