heimsventus

Dailies 5 6 7 c++

Feb 8th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.47 KB | None | 0 0
  1. // ConsoleApplication1.cpp : Defines the entry point for the console application.
  2. //
  3. #include "stdafx.h"
  4. #include <iostream>
  5. #include <cstdlib>
  6. #include <ctime>
  7. #include <cmath>
  8. #include <string>
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13.     double start = 0.01, sum = 0.0;
  14.  
  15.     for (int i = 1; i <= 30; i++)
  16.     {
  17.  
  18.         start = start * 2;
  19.         sum = sum + start;
  20.  
  21.     }
  22.     cout << " The total for the penny compounded daily is " << sum << endl;
  23.     cout << " This is end of dailies 5." << endl;
  24.     system("pause");
  25.  
  26.  
  27.     double number1 = 0;
  28.     double number2 = 1;
  29.     double number3;
  30.     double times = 0;
  31.     cout << " Enter number of fibonacci numbers to generate." << endl;
  32.     cin >> times;
  33.     cout << number1 << ", ";
  34.     cout << number2 << ", ";
  35.     for (int i = 1; i <= times; i++)
  36.     {
  37.         number3 = number1 + number2;
  38.         cout << number3 << ",";
  39.         number1 = number2;
  40.         number2 = number3;
  41.  
  42.  
  43.    
  44.        
  45.  
  46.        
  47.     }
  48.     cout << "This is the end of dailies 6." << "/n";
  49.     cout << " Ask a question." << endl;
  50.     char question;
  51.     cin >> question;
  52.     string response;
  53.     srand(time(NULL));
  54.     int randomnumber = rand() % 5 + 1;
  55.  
  56.             switch (randomnumber)
  57.             {
  58.             case 1:
  59.                 response = "yes"; break;
  60.             case 2:
  61.                 response = "No"; break;
  62.             case 3:
  63.                 response = "Maybe"; break;
  64.             case 4:
  65.                 response = "You may find out later."; break;
  66.             case 5:
  67.                 response = "This shit ain't random."; break;
  68.             }
  69.             cout << response << endl;
  70.  
  71.     cout << "This is the end of dailies 7." << endl;
  72.  
  73.     system("pause");
  74.     return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment