Activity 1
Exercise No. 1
#include <iostream>
using namespace std;
int main(){
int age;
cout << "Enter your age: ";
cin >> age;
cout << "You are " << age << " years old." << endl;
cout << "You are too young to play the game." << endl;
system("pause");
return 0;
}
Activity 1
Exercise No. 2
#include <iostream>
using namespace std;
int main(){
for(int i = 0; i < 5; i++){
for(int j = 0; j < 5; j++){
cout << "*";
}
cout << endl;
}
system("pause");
return 0;
}
Activity 1
Exercise No. 3
#include <iostream>
using namespace std;
int main(){
int x, y;
float z;
cout << "x: ";
cin >> x;
cout << "y: ";
cin >> y;
cout << "z: ";
cin >> z;
printf("x = %d y = %d z = %.1f\n", x, y, z);
system("pause");
return 0;
}
Activity 1
Exercise No. 4
# include <iostream>
using namespace std;
int main(){
char name [50];
cout << "Enter your name: ";
cin >> name;
cout <<"Hello " <<name <<endl;
system("pause");
return 0;
}
Activity 1
Exercise No. 5
#include <iostream>
using namespace std;
int main(){
int val_one, val_two, val_three;
cout << "val_one: ";
cin >> val_one;
cout << "val_two: ";
cin >> val_two;
cout << "val_three: ";
cin >> val_three;
int sum = val_one + val_two + val_three;
float ave = sum/5;
printf("The sum of %d + %d + %d = %d\n", val_one, val_two,
val_three,sum);
printf("The average is: %.0f\n", ave);
system("pause");
return 0;
}
Activity 2
Exercise No. 1
#include <iostream>
using namespace std;
int main(){
int numberone, numbertwo;
cout << "numberone: ";
cin >> numberone;
cout << "numbertwo: ";
cin >> numbertwo;
int sum = numberone + numbertwo;
printf("The sum of %d + %d = %d\n", numberone, numbertwo, sum);
system("pause");
return 0;
}
Activity 2
Exercise No. 2
#include <iostream>
using namespace std;
int main(){
float salesDiv, salesComp;
cout << "salesdiv: ";
cin >> salesDiv;
cout << "salescomp: ";
cin >> salesComp;
float totalSales = salesDiv * salesComp;
cout << "The total sales generated by the sales division is: $" <<
totalSales << " million" << endl;
system("pause");
return 0;
}
Activity 2
Exercise No. 3
#include <iostream>
using namespace std;
int main(){
float purchase, statetax, countrytax;
cout << "Purchase: ";
cin >> purchase;
cout << "State Tax: ";
cin >> statetax;
cout << "Country Tax: ";
cin >> countrytax;
statetax = statetax * purchase;
countrytax = countrytax * purchase;
float totalSalesTax = statetax + countrytax;
printf("The total sales tax on $%.2f purchase is $%.2f\n", purchase,
totalSalesTax);
system("pause");
return 0;
}
Activity 2
Exercise No. 4
#include <iostream>
using namespace std;
int main(){
float meal;
float tax;
float tip;
float total;
cout << "Input meal: ";
cin >> meal;
cout << "Input tax: ";
cin >> tax;
cout << "Input tip: ";
cin >> tip;
tax = tax * meal;
tip = (tax + meal) * tip;
total = meal + tax + tip;
cout << "The meal charge is: $" << meal << endl;
cout << "The tax amount is: $" << tax << endl;
cout << "The tip amount is: $" << tip << endl;
cout << "The total bill is: $" << total << endl;
system("pause");
return 0;
}
Activity 2
Exercise No. 5
#include <iostream>
using namespace std;
int main(){
int val_one, val_two, val_three, val_four, val_five;
cout << "val_one: ";
cin >> val_one;
cout << "val_two: ";
cin >> val_two;
cout << "val_three: ";
cin >> val_three;
cout << "val_four: ";
cin >> val_four;
cout << "val_five: ";
cin >> val_five;
int sum = val_one + val_two + val_three + val_four + val_five;
float ave = sum/5;
printf("The sum of %d + %d + %d + %d + %d = %d\n", val_one, val_two,
val_three, val_four, val_five, sum);
printf("The average is: %.0f\n", ave);
system("pause");
return 0;
}
Activity 2
Exercise No. 6
#include <iostream>
using namespace std;
int main(){
float payAmount, payPeriods, annualPay;
cout << "Pay Amount: ";
cin >> payAmount;
cout << "Pay Periods: ";
cin >> payPeriods;
annualPay = payAmount * payPeriods;
printf("The employee earns $%.2f each pay period.\n", payAmount);
printf("There are %.0f in a year.\n", payPeriods);
printf("The annual pay is: $%.2f.\n", annualPay);
system("pause");
return 0;
}
Activity 2
Exercise No. 7
#include <iostream>
using namespace std;
int main(){
float currentLevel, risingLevel;
cout << "Current Level: ";
cin >> currentLevel;
cout << "Rising Level: ";
cin >> risingLevel;
printf("In 5 years, the ocean's level will be %f higher than the current
level. \n", currentLevel + (risingLevel*5));
printf("In 7 years, the ocean's level will be %f higher than the current
level. \n", currentLevel + (risingLevel*7));
printf("In 10 years, the ocean's level will be %f higher than the current
level. \n", currentLevel + (risingLevel*10));
system("pause");
return 0;
}
Activity 2
Exercise No. 8
#include <iostream>
using namespace std;
int main(){
char month1[10], month2[10], month3[10];
float rain1, rain2, rain3;
cout << "Enter the name of the month: ";
cin >> month1;
cout << "Enter the rainfall (in inch): ";
cin >> rain1;
cout << "Enter the name of the month: ";
cin >> month2;
cout << "Enter the rainfall (in inch): ";
cin >> rain2;
cout << "Enter the name of the month: ";
cin >> month3;
cout << "Enter the rainfall (in inch): ";
cin >> rain3;
float ave = (rain1 + rain2 + rain3)/3;
printf("The average rainfall for %s, %s, and %s is: %.2f\n", month1,
month2, month3, ave);
system("pause");
return 0;
}
Activity 2
Exercise No. 9
#include <iostream>
using namespace std;
int main(){
char c;
int i;
float f;
double d;
cout << "The size of a char is: 1" << endl;
cout << "The size of an int is: 4" << endl;
cout << "The size of a float is: 4" << endl;
cout << "The size of a double is: 8" << endl;
system("pause");
return 0;
}
Activity 2
Exercise No. 10
#include <iostream>
using namespace std;
int main(){
float gallons, miles, MPG;
cout << "Enter the number of size of the tank (gallons): ";
cin >> gallons;
cout << "Enter the number of miles per tank of gas: ";
cin >> miles;
MPG = miles/gallons;
cout << "A car that holds " << gallons <<" gallons of gasoline and travel
" << miles << " miles before refueling gets " << MPG << "MPG" << endl;
system("pause");
return 0;
}
Activity 3
Exercise No. 1
#include <iostream>
using namespace std;
int main(){
float capacity, miles, average;
cout << "Enter the number of size of the tank (gallons): ";
cin >> capacity;
cout << "Enter the number of miles per tank of gas: ";
cin >> miles;
average = miles/capacity;
cout << "The car's MPG is: " << average << endl;
system("pause");
return 0;
}
Activity 3
Exercise No. 2
#include <iostream>
using namespace std;
int main(){
int classA, classB, classC;
cout << "How many tickets were sold for classA? ";
cin >> classA;
cout << "How many tickets were sold for classB? ";
cin >> classB;
cout << "How many tickets were sold for classC? ";
cin >> classC;
int numberA = classA, numberB = classB, numberC = classC;
int total = (numberA * classA) + (numberB * classB) + (numberC *
classC);
printf("Sales for Class A: $%d.00\n", numberA*classA);
printf("Sales for Class B: $%d.00\n", numberB*classB);
printf("Sales for Class C: $%d.00\n", numberC*classC);
printf("Total sales generated: $%d.00\n", total);
system("pause");
return 0;
}
Activity 3
Exercise No. 3
#include <iostream>
using namespace std;
int main(){
float score1, score2, score3, score4, score5;
cout << "Enter score 1: ";
cin >> score1;
cout << "Enter score 2: ";
cin >> score2;
cout << "Enter score 3: ";
cin >> score3;
cout << "Enter score 4: ";
cin >> score4;
cout << "Enter score 5: ";
cin >> score5;
float ave = (score1 + score2 + score3 + score4 + score5)/5;
printf("The average score is: %f\n", ave);
system("pause");
return 0;
}
Activity 3
Exercise No. 5
#include <iostream>
#include <string>
using namespace std;
int main(){
char movie[50];
float adultTickets, childTickets;
float adultPrice = 6.00, childPrice = 3.00;
float grossBox, netBox, distributorCut;
cout << "Enter the name of the movie: ";
[Link](movie, 50);
cout << "Enter number of adult tickets sold: ";
cin >> adultTickets;
cout << "Enter number of child tickets sold: ";
cin >> childTickets;
grossBox = (adultTickets * adultPrice) + (childTickets * childPrice);
netBox = grossBox * 0.20;
distributorCut = grossBox - netBox;
cout << "Movie Name: " << movie << endl;
cout << "Adult Tickets Sold: " << adultTickets << endl;
cout << "Child Tickets Sold: " << childTickets << endl;
printf("Gross Box Office Profit $%.2f\n", grossBox);
printf("Net Box Office Profit $%.2f\n", netBox);
printf("Amount Paid to Distributor:$%.2f\n", distributorCut);
system("pause");
return 0;
}
Activity 3
Exercise No. 6
#include <iostream>
#include <math.h>
using namespace std;
int main(){
float widgetWeight = 9.2;
float palletEmpty, palletWeight;
cout << "How much does the empty pallet weight (pound): ";
cin >> palletEmpty;
cout << "How much does the pallet weight (with widgets): ";
cin >> palletWeight;
float widgetNumber = ceil((palletWeight - palletEmpty) /
widgetWeight);
cout << "***************************************" << endl;
cout << "There are " << widgetNumber << " widgets on the pallet" <<
endl;
system("pause");
return 0;
}
Activity 3
Exercise No. 7
#include <iostream>
using namespace std;
int main(){
int cookies;
cout << "Enter the number of cookies you ate: ";
cin >> cookies;
int totalCalories = cookies * 75;
cout << "*******************************" << endl;
cout << "You consumed: " << totalCalories << " Calories" << endl;
system("pause");
return 0;
}
Activity 3
Exercise No. 8
#include <iostream>
using namespace std;
int main(){
int repCost;
cout << "Enter the replacement cost of your building: ";
cin >> repCost;
cout << " *******************************" << endl;
cout << " \"Minimum insurance recommended\"" << endl;
cout << " *******************************" << endl;
cout << "Enter the replacement cost of your building: $" << repCost <<
endl;
cout << " The minimum insurance you should buy is: $8000" << endl;
system("pause");
return 0;
}
Activity 3
Exercise No. 9
#include <iostream>
using namespace std;
int main() {
float loanPayment, monthlyTotal, insurance, gas, oil, tires,
maintenance;
cout << "Enter your monthly loan payment: ";
cin >> loanPayment;
cout << "Enter your monthly insurance: ";
cin >> insurance;
cout <<"Enter your monthly gas expenses: ";
cin >> gas;
cout <<"Enter your monthly oil expenses: ";
cin >> oil;
cout <<"Enter your monthly tires expenses: ";
cin >> tires;
cout <<"Enter your monthly maintenance expenses: ";
cin >> maintenance;
float montlhlyTotal = loanPayment + insurance + gas + oil + tires +
maintenance;
float annualTotal = monthlyTotal * 12;
cout << "*********************************************" <<
endl;
printf("Your total monthly expenses are: $%.2f\n", monthlyTotal);
printf("Your annual expenses are: $%.2f\n", annualTotal);
}
Activity 3
Exercise No. 10
#include <iostream>
using namespace std;
int main(){
float celsius;
cout << "Enter Celsius Temperature: ";
cin >> celsius;
float fahrenheit = (1.8 * celsius) + 32;
cout << celsius << " Celsius = " << fahrenheit << " Fahrenheit" << endl;
system("pause");
return 0;
}