Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- #include <cstdlib>
- #include <ctime>
- #include <fstream>
- using namespace std;
- int main()
- {
- float weight;
- float height;
- cout << "In pounds, how much do you weigh?" << endl;
- cin >> weight;
- cout << "In inches, how tall are you?" << endl;
- cin >> height;
- float bmi = (weight * .45) / pow((height * .025), 2);
- cout << "BMI: " << bmi << endl;
- if (bmi >= 40) { cout << "Category: Obese Class III (very severely obese)" << endl; }
- else if (bmi >= 35) { cout << "Category: Obese Class II (severely obese)" << endl; }
- else if (bmi >= 30) { cout << "Category: Obese Class I (moderately obese)" << endl; }
- else if (bmi >= 25) { cout << "Category: Overweight" << endl; }
- else if (bmi >= 18.5) { cout << "Category: Normal (healthy weight)" << endl; }
- else if (bmi >= 16) { cout << "Category: Underweight" << endl; }
- else if (bmi >= 15) { cout << "Category: Severely Underweight" << endl; }
- else { cout << "Category: Very Severely Underweight" << endl; };
- cout << "---------- End of Daily 1 ----------\n\n\n";
- string eightQ;
- string repeatQ;
- string response1 = "It is certain";
- string response2 = "It is decidedly so";
- string response3 = "Reply hasy try again";
- string response4 = "Ask again later";
- string response5 = "Don't count on it";
- string response6 = "Very doubtful";
- do
- {
- srand(time(NULL));
- int randomNumber = rand() % 6 + 1;
- cout << "What would you like to know? Please ask the Magic 8-Ball a yes or no question." << endl;
- cin >> eightQ;
- switch (randomNumber)
- {
- case 1: cout << response1 << endl;
- break;
- case 2: cout << response2 << endl;
- break;
- case 3: cout << response3 << endl;
- break;
- case 4: cout << response4 << endl;
- break;
- case 5: cout << response5 << endl;
- break;
- case 6: cout << response6 << endl;
- break;
- }
- cout << "Do you wish to play again?";
- cin >> repeatQ;
- } while (repeatQ != "quit");
- cout << "---------- End of Daily 2 ----------\n\n\n";
- float loanAmount;
- int loanTerm;
- float annualRate;
- cout << "What is your loan amount?" << endl;
- cin >> loanAmount;
- cout << "What is your annual interest rate? (.##)" << endl;
- cin >> annualRate;
- cout << "What is your loan term in months?" << endl;
- cin >> loanTerm;
- float monthlyPayment = ((annualRate / 12) * loanAmount * pow((1 + (annualRate / 12)), loanTerm)) / (pow((1 + (annualRate / 12)), loanTerm) - 1);
- cout << "Monthly Payment Amount: " << monthlyPayment << endl;
- for (size_t i = 0; i < loanTerm; i++)
- {
- float interest = (annualRate / 12) * loanAmount;
- float principal = monthlyPayment - interest;
- float balance = loanAmount - principal;
- cout << "Principal #: " << i + 1 << " " << principal << " Interest: " << interest << " Balance: " << balance << endl;
- loanAmount = balance;
- };
- cout << "---------- End of Daily 3 ----------\n\n\n";
- string playagain;
- int guess;
- do
- {
- srand(time(NULL));
- int randomN100 = rand() % 100 + 1;
- cout << "I'm thinking of a number between 1 and 100...\n\n";
- do
- {
- cout << "Guess: ";
- cin >> guess;
- if (guess > randomN100) cout << "Your guess is too high.\n";
- if (guess < randomN100) cout << "Your guess is too low.\n";
- } while (guess != randomN100);
- cout << "Your guess is correct!\n\n";
- cout << "Do you wish to play again? ";
- cin >> playagain;
- } while (playagain != "quit");
- cout << "---------- End of Daily 4 ----------\n\n\n";
- ifstream rainSheet;
- float dailyRain;
- float totalRain = 0;
- rainSheet.open("C:\\Users\\cis.LABS\\Downloads\\rainfall.txt", ios::in);
- rainSheet >> dailyRain;
- int i = 0;
- while (!rainSheet.eof() && dailyRain != -999)
- {
- if ( dailyRain >= 0)
- {
- i++;
- totalRain +=dailyRain;
- }
- rainSheet >> dailyRain;
- }
- cout << "Average rain over " << i << " days is: " << totalRain / i << endl;
- cout << "---------- End of Daily 5 ----------\n\n\n";
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement