Using my very rendundant method of programming, I have almost fully completed my program.If you look at my program now you could see how I have incorporated suggestsions from this forum and other into the program Currently i get no errors while compiling, but my averages are giving me weird numbers such as 1.0990e+9. If you could help me with the last aspect of my code I would be eternaly greatful
Code:

//--------------------------------------------------------------------------------------
#include <iostream.h >
#include <math.h>
#include <apstring.cpp>
//--------------------------------------------------------------------
double cat01()
/* Gets the average of up to 9 numbers worth x% of the grade */
{
        double a1;
        double a2;
        double a3;
        double a4;
        double a5;
        double a6;
        double a7;
        double a8;
        double a9;
        double addition;
        double average;
        double y;
        double numgrade;
    cout << "Enter the amount of grades ";
    cin >> numgrade;
    y=0;
    
    if (numgrade >0)
    cin >> a1;
    numgrade--;
        y++;
    if (numgrade >0)
        cin >> a2;
        y++;
        numgrade--;
    if (numgrade >0)    
    cin >> a3;
        y++;
        numgrade--;
    if (numgrade >0)     
    cin >> a4;
        y++;
        numgrade--;
    if (numgrade >0)     
    cin >> a5;
        y++;
        numgrade--;
 if (numgrade >0)
        cin >> a6;
        y++;
        numgrade--;
 if (numgrade >0)
    cin >> a7;
    y++;
    numgrade--;
 if (numgrade >0)
    cin >> a8;
    y++;
    numgrade--;
 if (numgrade >0)
    cin >> a9;
    y++;
    numgrade--;
    
    addition= a1+a2+a3+a4+a5+a6+a7+a8+a9;
    average= (double)addition/y;
    return average;
    
    }
//--------------------------------------------------------------------------------------



//--------------------------------------------------------------------------------------
int main()

{
    apstring cat1;
    apstring cat2;
    apstring cat3;
    apstring cat4;
    apstring cat5;
    apstring cat6;
    apstring cat7;
    apstring cat8;
    apstring cat9;
    double numcat;
    double numcat3;
    double numcat4;
    double numcat5;
    double percent1;
    double percent2;
    double percent3;
    double percent4;
    double percent5;
    double percent6;
    double percent7;
    double percent8;
    double percent9;
    double average1=0;
    double average2=0;
    double average3=0;
    double average4=0;
    double average5=0;
    double average6=0;
    double average7=0;
    double average8=0;
    double average9=0;
    double final1;
    double final2;
    double final3;
    double final4;
    double final5;
    double final6;
    double final7;
    double final8;
    double final9;
    double ultfinaladd;
    double ultfinal;
    char yn;

    do {
    cout << "Enter the amount of categories :";
    cin >> numcat;
    cout << "Enter the names of the categories : "<< endl;
    
 if (numcat >0)
    cin >> cat1;
    numcat--;
 if (numcat >0)
    cin >> cat2;
    numcat--;
 if (numcat >0)
    cin >> cat3;
    numcat--;
 if (numcat >0)
    cin >> cat4;
    numcat--;
 if (numcat >0)
    cin >> cat5;
    numcat--;
 if (numcat >0)
    cin >> cat6;
    numcat--;
 if (numcat >0)
    cin >> cat7;
    numcat--;
 if (numcat >0)
    cin >> cat8;
    numcat--;
 if (numcat >0)
    cin >> cat9;
    numcat--;
    
    cout << "Please re-enter the amount of categories"<< endl;
    cin >> numcat3;
    cout << "Enter how much of the percent is each category worth (in decimal form) : ";
    
    
if (numcat3 > 0)
        cin >> percent1;
        numcat3--;
 if (numcat3 >= 0)
        cin >> percent2;
        numcat3--;
 if (numcat3 > 0)
        cin >> percent3;
        numcat3--;
 if (numcat3 > 0)
        cin >> percent4;
        numcat3--;
 if (numcat3 > 0)
        cin >> percent5;
        numcat3--;
 if (numcat3 > 0)
        cin >> percent6;
        numcat3--;
 if (numcat3 > 0)
        cin >> percent7;
        numcat3--;
 if (numcat3 > 0)
        cin >> percent8;
        numcat3--;
 if (numcat3 > 0)
        cin >> percent9;
        numcat3--;
    
    cout << "Please re-enter the amount of categories"<< endl;
    cin >> numcat4;
if (numcat4 > 0)
    average1 = cat01();
    numcat4--;
if (numcat4 > 0)
    average2 = cat01();
    numcat4--;
if (numcat4 > 0)
    average3 = cat01();
    numcat4--;
if (numcat4 > 0)
    average4 = cat01();
    numcat4--;
if (numcat4 > 0)
    average5 = cat01();
    numcat4--;
if (numcat > 0)
    average6 = cat01();
    numcat4--;
if (numcat4 > 0)
    average7 = cat01();
    numcat4--;
if (numcat4 > 0)
    average8 = cat01();
    numcat4--;
if (numcat4 > 0)
    average9 = cat01();
    numcat4--;

    
    

    cout << "Please re-enter the amount of categories"<< endl;
    cin >> numcat5;
if (numcat5 > 0)
    cout << "The average of " << cat1 << " is" << average1 << endl;
    numcat5--;
if (numcat5 > 0)
    cout << "The average of " << cat2 << " is" << average2 << endl;
    numcat5--;
if (numcat5 > 0)
    cout << "The average of " << cat3 << " is" << average3 << endl;
    numcat5--;
if (numcat5 > 0)
    cout << "The average of " << cat4 << " is" << average4 << endl;
    numcat5--;
if (numcat5 > 0)
    cout << "The average of " << cat5 << " is" << average5 << endl;
    numcat5--;
if (numcat5 > 0)
    cout << "The average of " << cat6 << " is" << average6 << endl;
    numcat5--;
if (numcat5 > 0)
cout << "The average of " << cat7 << " is" << average7 << endl;
numcat5--;
if (numcat5 > 0)
cout << "The average of " << cat8 << " is" << average8 << endl;
numcat5--;
if (numcat5 > 0)
cout << "The average of " << cat9 << " is" << average9 << endl;
numcat5--;
double numcat9;
cout << "Enter the amount of categories again" << endl;
cin >> numcat9;



final1=average1*percent1;
final2=average2*percent2;
final3=average3*percent3;
final4=average4*percent4;
final5=average5*percent5;
final6=average6*percent6;
final7=average7*percent7;
final8=average8*percent8;
final9=average9*percent9;
ultfinaladd= average1+average2+average3+average4+average5+average6+average7+average8+average9;
ultfinal= (double)ultfinaladd/numcat9;
cout << "Your final grade is " << ultfinal << "percent" << endl;
if (ultfinal < 60)
   cout << "You failed!" << endl;
else if (ultfinal < 70 && ultfinal >= 60)
     cout << "You barely passed with a D!" << endl;
else if (ultfinal < 80 && ultfinal >= 70)
     cout << "You passed with a C!" << endl;
else if (ultfinal < 90 && ultfinal >= 80)
     cout << "You did great with a B!" << endl;
else if (ultfinal < 100 && ultfinal >= 90)
     cout << "You did great and got an A!" << endl;
else if (ultfinal >= 100)
     cout << "Amazing! You got a perfect score!" << endl;
    cout << "If you would like to continue type Y. If you would like to stop press N . ";
    cin >> yn;
    
} while (yn == 'Y' || yn == 'y');
  if (yn == 'N' || yn == 'n')
    cout << "Thank you for using Daniel Gonzalez's Grade Calculator!" << endl;
    cout << "Have a nice day!" << endl;
    return(0);
}

P.S. instead of repeating this course in school, I plan on taking the class at a community-college in my area. Hopefully I will receive better instruction/ learn more