1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <iomanip>
using namespace std;
int main ()
{
srand(time(0));
char ch;
int ex;
cout<<"Which excerise? ";
cin>>ex;
cout<<endl;
if (ex == 1)
{
double beg, end;
int num;
cout<<"Enter beginning and ending numbers, seperated by space: "<<endl;
cin>>beg;
cin>>end;
cout<<endl;
for (num=beg; num<=end; ++num)
{
cout<<num<<","<<" ";
}
cout<<endl;
cout<<endl;
cout<<"Enter beginning and ending numbers, seperated by space: "<<endl;
cin>>beg;
cin>>end;
cout<<endl;
for (num=beg; num<=end; num++)
{
cout<<num<<","<<" ";
num+=1;
}
cout<<endl;
cout<<endl;
cout<<"Enter the beginning and largest positive numbers, seperated by space: "<<endl;
cin>>beg;
cin>>end;
cout<<endl;
for (num=beg; num<=end; num)
{
cout<<num<<","<<" ";
num*=-2;
}
cout<<endl;
cout<<endl;
}
if (ex == 2)
{
int grade;
double A, B, C, D, F;
A=0;
B=0;
C=0;
D=0;
F=0;
cout<<"Enter one or more grades, or -1 to stop:"<<endl;
do
{
cin>>grade;
if (grade>=90) A++;
if ((grade>=80) && (grade<=89)) B++;
if ((grade>=70) && (grade<=79)) C++;
if ((grade>=60) && (grade<=69)) D++;
if ((grade>=0) && (grade<=59)) F++;
}
while (grade!=-1);
{
cout<<"The grades breakdown is:"<<endl;
cout<<"A's: "<<A<<endl;
cout<<"B's: "<<B<<endl;
cout<<"C's: "<<C<<endl;
cout<<"D's: "<<D<<endl;
cout<<"F's: "<<F<<endl;
}
}
if (ex == 3)
{
double again, yes;
int heads, tails;
cout<<"Toss the coin? "<<endl;
cin>>again;
while (again==yes)
{
int random_number = rand()%2;
if (random_number==0)
{
cout<<"Heads"<<endl;
}
if (random_number==1)
{
cout<<"Tails"<<endl;
}
}
}
return 0;
}
|