hey, im new to the whole programming scene and i made this code to find the mean avrage of things. problem is i cannot get it to do more than three numbers. i will post the code and if you can make any changes to hellp and just leave a post id be more than grateful. thanks in advance.
sam
code;
Code:#include <iostream> using namespace std; int main() { int amount_of_numbers, average, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10; cout<<"hello, this program will identify the mean average of a group of numbers that you will input"<<endl; cin.get(); cout<<"please input amount of numbers in group (min - 3, max - 10).\n"; cin >> amount_of_numbers; if (amount_of_numbers >= 3) { cout<<"please input first number.\n"; cin >> n1; cout<<"please input second number.\n"; cin >> n2; cout<<"please input last number.\n"; cin >> n3; average = n1+n2+n3/amount_of_numbers; cout<<"the average mean of this group of numbers is:"; cout<< average; } else if (amount_of_numbers >= 4) { cout<<"please input first number.\n"; cin >> n1; cout<<"please input second number.\n"; cin >> n2; cout<<"please input third number.\n"; cin >> n3; cout<<"please input last number.\n"; cin >> n4; average = n1+n2+n3+n4/amount_of_numbers; cout<<"the average mean of this group of numbers is:"; cout<< average; } else if (amount_of_numbers >= 5) { cout<<"please input first number.\n"; cin >> n1; cout<<"please input second number.\n"; cin >> n2; cout<<"please input third number.\n"; cin >> n3; cout<<"please input fourth number.\n"; cin >> n4; cout<<"please input last number.\n"; cin >> n5; average = n1+n2+n3+n4+n5/amount_of_numbers; cout<<"the average mean of this group of numbers is:"; cout<< average; } else if (amount_of_numbers = 6) { cout<<"please input first number.\n"; cin >> n1; cout<<"please input second number.\n"; cin >> n2; cout<<"please input third number.\n"; cin >> n3; cout<<"please input fourth number.\n"; cin >> n4; cout<<"please input fifth number.\n"; cin >> n5; cout<<"please input last number.\n"; cin >> n6; average = n1+n2+n3+n4+n5+n6/amount_of_numbers; cout<<"the average mean of this group of numbers is:"; cout<< average; } else if (amount_of_numbers >= 7) { cout<<"please input first number.\n"; cin >> n1; cout<<"please input second number.\n"; cin >> n2; cout<<"please input third number.\n"; cin >> n3; cout<<"please input fourth number.\n"; cin >> n4; cout<<"please input fifth number.\n"; cin >> n5; cout<<"please input sixth number.\n"; cin >> n6; cout<<"please input last number.\n"; cin >> n7; average = n1+n2+n3+n4+n5+n6+n7/amount_of_numbers; cout<<"the average mean of this group of numbers is:"; cout<< average; } else if (amount_of_numbers >= 8) { cout<<"please input first number.\n"; cin >> n1; cout<<"please input second number.\n"; cin >> n2; cout<<"please input third number.\n"; cin >> n3; cout<<"please input fourth number.\n"; cin >> n4; cout<<"please input fifth number.\n"; cin >> n5; cout<<"please input sixth number.\n"; cin >> n6; cout<<"please input seventh number.\n"; cin >> n7; cout<<" please input last number.\n"; cin >> n8; average = n1+n2+n3+n4+n5+n6+n7+n8/amount_of_numbers; cout<<"the average mean of this group of numbers is:"; cout<< average; } else if (amount_of_numbers >= 8) { cout<<"please input first number.\n"; cin >> n1; cout<<"please input second number.\n"; cin >> n2; cout<<"please input third number.\n"; cin >> n3; cout<<"please input fourth number.\n"; cin >> n4; cout<<"please input fifth number.\n"; cin >> n5; cout<<"please input sixth number.\n"; cin >> n6; cout<<"please input seventh number.\n"; cin >> n7; cout<<"please input eighth number.\n"; cin >> n8; cout<<"please input ninth number.\n"; cin >> n9; average = n1+n2+n3+n4+n5+n6+n7+n8+n9/amount_of_numbers; cout<<"the average mean of this group of numbers is:"; cout<< average; } else if (amount_of_numbers >= 8) { cout<<"please input first number.\n"; cin >> n1; cout<<"please input second number.\n"; cin >> n2; cout<<"please input third number.\n"; cin >> n3; cout<<"please input fourth number.\n"; cin >> n4; cout<<"please input fifth number.\n"; cin >> n5; cout<<"please input sixth number.\n"; cin >> n6; cout<<"please input seventh number.\n"; cin >> n7; cout<<"please input eighth number.\n"; cin >> n8; cout<<"please input ninth number.\n"; cin >> n9; cout<<"please input thenth number.\n"; cin >> n10; average = n1+n2+n3+n4+n5+n6+n7+n8+n9+n10/amount_of_numbers; cout<<"the average mean of this group of numbers is:"; cout<< average; } }



LinkBack URL
About LinkBacks



