Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions auto.cpp.c++
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <iostream>
using namespace std;

int main() {
double tankCapacity, milesPerGallon, totalMiles;

cout << "Enter the fuel tank capacity of the automobile (in gallons): ";
cin >> tankCapacity;

cout << "Enter the miles per gallon (MPG) the automobile can be driven: ";
cin >> milesPerGallon;

totalMiles = tankCapacity * milesPerGallon;

cout << "The automobile can be driven " << totalMiles << " miles without refueling." << endl;

return 0;
34 changes: 34 additions & 0 deletions body.cpp.c++
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <iostream>
using namespace std;
int main() {
int numPeople;


cout << "How many people do you want to calculate BMI for? ";
cin >> numPeople;
for (int i = 1; i <= numPeople; ++i) {

double weight, height, bmi;
cout << "\nPerson " << i << endl;
cout << "Enter weight in kilograms: ";
cin >> weight;
cout << "Enter height in meters: ";
cin >> height;

bmi = weight / (height * height);

cout << "Your BMI is: " << bmi << endl;

if (bmi < 18.5) {
cout << "You are underweight." << endl;
} else if (bmi >= 18.5 && bmi < 24.9) {
cout << "You have a normal weight." << endl;
} else if(bmi > 25) {
cout << "You are overweight." << endl;
}
}

cout << "\nThank you for using the BMI calculator!" << endl;

return 0;
}
17 changes: 17 additions & 0 deletions pow.cpp.c++
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double X, Y, result;
cout << "Enter the value of X (base): ";
cin >> X;

cout << "Enter the value of Y (exponent): ";
cin >> Y;

result = pow(X, Y);

cout << "The result of " << X << "^" << Y << " is: " << result << endl;

return 0;
}
40 changes: 40 additions & 0 deletions rate.cpp.c++
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <iostream>
#include <string>
#include <iomanip> // For formatting output
using namespace std;

int main() {
string name;
double workingHours, bonusRate, baseSalary;
double bonusPayment, grossSalary, pensionDeduction, taxDeduction, netSalary;
cout << "Enter the employee's name: ";
getline(cin, name);

cout << "Enter the weekly working hours: ";
cin >> workingHours;

cout << "Enter the bonus rate per hour: ";
cin >> bonusRate;

cout << "Enter the base salary: ";
cin >> baseSalary;

bonusPayment = bonusRate * workingHours;
grossSalary = baseSalary + bonusPayment;

pensionDeduction = grossSalary * 0.05;
taxDeduction = grossSalary * 0.15;

netSalary = grossSalary - pensionDeduction - taxDeduction;

cout << fixed << setprecision(2); // Format output to 2 decimal places
cout << "\nEmployee Name: " << name << endl;
cout << "Base Salary: $" << baseSalary << endl;
cout << "Bonus Payment: $" << bonusPayment << endl;
cout << "Gross Salary: $" << grossSalary << endl;
cout << "Pension Deduction (5%): $" << pensionDeduction << endl;
cout << "Tax Deduction (15%): $" << taxDeduction << endl;
cout << "Net Salary after deductions: $" << netSalary << endl;

return 0;
}
32 changes: 32 additions & 0 deletions size.cpp.c++
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <iostream>
#include <iomanip>
using namespace std;

int main() {
const int transmissionRate= 960;
const double fileSizeMB = 400.0;

int bytesInMB = 1048576;
double fileSizeBytes = fileSizeMB * bytesInMB;

double timeInSeconds = fileSizeBytes / transmissionRate;

int days = timeInSeconds / 86400;
timeInSeconds -= days * 86400;

int hours = timeInSeconds / 3600;
timeInSeconds -= hours * 3600;

int minutes = timeInSeconds / 60;
timeInSeconds -= minutes * 60;

int seconds = static_cast<int>(timeInSeconds);

cout << fixed << setprecision(2);
cout << "Time to send a " << fileSizeMB << " MB file at " << transmissionRate
<< " characters per second:" << endl;
cout << "Days: " << days << ", Hours: " << hours << ", Minutes: " << minutes
<< ", Seconds: " << seconds << endl;

return 0;
}