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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
#include <iostream>
using namespace std;
int addition(int a, int b, int c, int d){
return a+b+c+d;
}
double avrg(int num, int num2, int num3, int num4){
return (num+num2+num3+num4)/4;
}
int multi(int ab, int bc, int cd, int de){
return ab*bc*cd*de;
}
string personality(int l, int m, int n, int o, int av){
av=(l+m+n+o)/4;
if(av>50){
if(l>0 && m>0 && n>0 && o>0){
return "When it comes to your number personality, you are a straight shooter";
}else if(l<0 && m<0 && n<0 && o<0){
return "When it comes to your number personality, you are a paradox";
}else{
return "When it comes to your number personality, you are an optimist";
}
}else if(av<-50){
if(l>0 && m>0 && n>0 && o>0){
return "When it comes to your number personality, you are a paradox";
}else if(l<0 && m<0 && n<0 && o<0){
return "When it comes to your number personality, you are a pessimist";
}else{
return "When it comes to your number personality, you are a negative nancy";
}
}else{
if(l>0 && m>0 && n>0 && o>0){
return "When it comes to your number personality, you are an apathetic";
}else if(l<0 && m<0 && n<0 && o<0){
return "When it comes to your number personality, you are a realist";
}else{
return "When it comes to your number personality, you are cautious";
}
}
}
int main() {
double one,two,three,four;
int menu;
int av= (one+two+three+four)/4;
cout << "Enter your first number: ";
cin >> one;
cout << "Enter your second number: ";
cin >> two;
cout << "Enter your third number: ";
cin >> three;
cout << "Enter your fourth number: ";
cin >> four;
if(one<-100||one>100){
while(one<-100||one>100){
cout << "Make sure that your number is between -100 to 100\n";
cout << "Enter your first number: ";
cin >> one;
}
}
if(two<-100||two>100){
while(two<-100||two>100){
cout << "Make sure that your number is between -100 to 100\n";
cout << "Enter your second number: ";
cin >> two;
}
}
if(three<-100||three>100){
while(three<-100||three>100){
cout << "Make sure that your number is between -100 to 100\n";
cout << "Enter your third number: ";
cin >> three;
}
}
if(four<-100||four>100){
while(four<-100||four>100){
cout << "Make sure that your number is between -100 to 100\n";
cout << "Enter your fourth number: ";
cin >> four;
}
}
cout << "1. Find the sum of the 4 numbers.\n2. Find the average of the 4 numbers.\n3. Find the product of the 4 numbers.\n4. Tell the user their “number personality” based on the following table\n";
cout << "5. Prime Numbers" << endl;
cout << "6. Change Numbers" << endl;
cout << "7. The Great Positizer" << endl;
cout << "8. The Great Equalizer\n9. Cream of the crop\n10. Exit\nChoice: ";
cin >> menu;
switch(menu){
case 1:
cout << "This is the sum of your numbers " << endl;
cout << addition(one, two, three, four) << endl;
return 0;
break;
case 2:
cout << "This is the average of your numbers : " << endl;
cout << avrg(one, two, three, four) << endl;
return 0;
break;
case 3:
cout << "This is the product of your numbers : " << endl;
cout << multi(one, two, three, four) << endl;
return 0;
break;
case 4:
cout << personality(one, two, three, four, av);
return 0;
break;
}
if(menu!=5){
while(menu!=5){
cout << "1. Find the sum of the 4 numbers.\n2. Find the average of the 4 numbers.\n3. Find the product of the 4 numbers.\n4. Tell the user their “number personality” based on the following table\n";
cout << "5. Exit\nChoice: ";
cin >> menu;
switch(menu){
case 1:
cout << "This is the sum of your numbers " << endl;
cout << addition(one, two, three, four) << endl;
return 0;
break;
case 2:
cout << "This is the average of your numbers : " << endl;
cout << avrg(one, two, three, four) << endl;
return 0;
break;
case 3:
cout << "This is the product of your numbers : " << endl;
cout << multi(one, two, three, four) << endl;
return 0;
break;
case 4:
cout << personality(one, two, three, four, av);
return 0;
break;
}
}
}
}
|