Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8940575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:04:12+00:00 2026-06-15T11:04:12+00:00

I present to you all a program I’m working on for my college programming

  • 0

I present to you all a program I’m working on for my college programming course. I still have a little ways to go before it completely meets my assignment’s requirements, but I’ve gotten a basic draft of the program error-free (supposedly) and it appears to run… but then it suddenly kicks me into Xcode’s debugger and gives me:

Thread 1: EXC_BAD_ACCESS(code=2, address=0x7fff95c1e5f5)

Here’s the command line output, up until it kicks me out:

    -----------------------
    Quarterly_sales_taxator
    -----------------------


    How many company divisions will we be dealing with?  2


    Am I correct in assuming that there are 4 sales quarters?    yes



    Please enter the sales Company Division #1 brought in for Sales Quarter #1   20
    (lldb)

Here’s my code:

    //
    //  quarterly_sales_taxator.cpp
    //  Ch. 7 program #7
    //
    //  Created by John Doe on 11/27/12.
    //

    #include <iostream>
    #include <iomanip>
    #include <string>
    #include <sstream>
    #include <cctype>
    using namespace std;

    void read_company_divisions_and_sales_quarters(double **, int, int);
        //void write_company_divisions_and_sales_quarters_to_array(double **, int, int);    // This will be used later on to read data from a file.
    void display_quarterly_sales_array(double **, int, int);

    string temp;    // A global temporary placeholder variable; I use this several times.


    int main()
    {
        int COMPANY_DIVISIONS,
            SALES_QUARTERS = 4;

        double **quarterly_sales_form;


        cout << "\n\n-----------------------\nQuarterly_sales_taxator\n-----------------------\n\n";

        cout << "\nHow many company divisions will we be dealing with?  ";
        getline(cin, temp);
        stringstream(temp)>>COMPANY_DIVISIONS;

        while (COMPANY_DIVISIONS < 1 || isdigit(COMPANY_DIVISIONS == false))
        {
            cout << "\n\n------"
                 << "\nError:"
                 << "\n------"
                 << "\n\nYou have entered an invalid choice."
                 << "\nPlease type a number greater than zero.    ";

            getline(cin, temp);
            stringstream(temp)>>COMPANY_DIVISIONS;
        }

        cout << "\n\nAm I correct in assuming that there are 4 sales quarters?    ";
        getline(cin, temp);

                // Convert to uppercase.
            for (int count = 0; count < temp.length(); count ++)
            {
                temp[count] = toupper(temp[count]);
            }

            if (temp == "NO" || temp == "NOPE" || temp == "INCORRECT" || temp == "YOU ARE NOT" || temp == "YOU ARE INCORRECT" || temp == "NEGATIVE" || temp == "NEGATORY")
            {
                cout << "\nOk, then how many sales quarters are we dealing with?    ";
                getline(cin, temp);
                stringstream(temp)>>SALES_QUARTERS;
            }

        cout << endl << endl;

            // This sets up the 2d array.
        quarterly_sales_form = new double *[COMPANY_DIVISIONS];
        for (int count = 0; count < COMPANY_DIVISIONS; count ++)
        {   quarterly_sales_form[COMPANY_DIVISIONS] = new double [SALES_QUARTERS];  }

        read_company_divisions_and_sales_quarters(quarterly_sales_form, COMPANY_DIVISIONS, SALES_QUARTERS);
            //  write_company_divisions_and_sales_quarters_to_array(quarterly_sales_form, COMPANY_DIVISIONS, SALES_QUARTERS);   // I'll add this feature later.


        cout << "\n\nHere's what you entered:\n\n";
        display_quarterly_sales_array(quarterly_sales_form, COMPANY_DIVISIONS, SALES_QUARTERS);

            // Since we used a series of pointers, we need to free the allocated space back up.
        for (int count = 0; count < COMPANY_DIVISIONS; count ++)
        {   delete[] quarterly_sales_form[COMPANY_DIVISIONS];  }
        delete[] quarterly_sales_form;



        return 0;
    }


    /*############################################
     # read_company_divisions_and_sales_quarters #
     ############################################*/
    void read_company_divisions_and_sales_quarters(double **array, int DIVISIONS, int QUARTERS)
    {

            for (int count = 0; count < QUARTERS; count++)
            {

                for (int index = 0; index < DIVISIONS; index++)
                {
                    cout << "\nPlease enter the sales Company Division #" << count+1 << " brought in for Sales Quarter #" << index+1 << "   ";
                    getline(cin, temp);
                    stringstream(temp) >> array[count][index];
                }
            }
    }


    /*################################
     # display_quarterly_sales_array #
     #################################*/
    void display_quarterly_sales_array(double **array, int DIVISIONS, int QUARTERS)
    {
        for (int count = 0; count < DIVISIONS; count++)
        {
            cout << "\nCompany division #" << count+1 << ":\n";
            for (int index = 0; index < QUARTERS; index++)
            {    cout << array[count][index] << ", ";    }
        }

    }

Can some kind soul please tell me what I’m doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:04:14+00:00Added an answer on June 15, 2026 at 11:04 am
        {   quarterly_sales_form[COMPANY_DIVISIONS] = new double [SALES_QUARTERS];  }
    

    In this line, COMPANY_DIVISIONS should be count.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 tables, Categories and Sub Categories. Is it prossible to present all
Present Scenario : I have a set of classes that all take a common
There is any ways to listing all main directories present in php server(may it
I have been working on a program that will enable me to monitor which
is it possible to check if any CUDA devices are present before all cudaMalloc...
I wrote a program in PHP to find and print all links present on
(This is a question about a vague problem. I try to present all relevant
The default Cassandra systems keyspace system is present in all Cassandra installations. Judging from
I want to show all users present in a database. I want to place
Is there a plugin/trick/macro for visual studio which automatically moves all files present outside

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.