//prepare the match inequality coefficient vector beforehand 
void ProfileMatchView::setupMatchStatisticsVector(QVector<int> indexDPVector, QVector<int> indexSPVector)
{
	float tempIC = 0.0;
	float tempCC = 0.0;
	float tempTD = 0.0;
	float tempTS = 0.0;
	float tempED = 0.0;
	float tempES = 0.0;
	QVector<float> tempTotalDemand;
	QVector<float> tempTotalSupply;
	
	tempTotalDemand.clear();
	tempTotalSupply.clear();
//	pMatchICVector.clear();
//	pMatchCCVector.clear();
//	pMatchEDVector.clear();
//	pMatchESVector.clear();
//	pMatchTDVector.clear();
//	pMatchTSVector.clear();
//calculate the total demand and push back to the tempTotalDemand vector
	for (int i = 0; i <  m_pDemandProfileList[m_iDsValue].second[0].m_pDemandDataVector.size(); i++)
	{
		tempTD = 0.0;
		tempTS = 0.0;
		for (int j = 0; j < indexDPVector.size(); j++)
		{
			tempTD = + m_pDemandProfileList[m_iDsValue].second[indexDPVector[j]].m_pDemandDataVector[i];
		}
		tempTotalDemand.append(tempTD);

		for (int k = 0; k < indexSPVector.size(); k++)
		{
			tempTS = + m_pSupplyProfileList[m_iSsValue].second[indexSPVector[k]].m_pSupplyDataVector[i];
		}
		tempTotalSupply.append(tempTS);
	}


//	for (int i=0; i<pMatchIdVector.size(); i++) //the total number of combinations
//	{

		tempIC = calculateInequalityCoefficient(tempTotalDemand, tempTotalSupply); //inequality coefficient
		tempCC = calculateSpearmansCorrelation(tempTotalDemand, tempTotalSupply); //correlation coefficient
		tempED = calculateDeficitCurveAreas(tempTotalDemand, tempTotalSupply); //energy deficit
		tempES = calculateSurplusCurveAreas(tempTotalDemand, tempTotalSupply); //energy surplus
		tempTD = calculateTotal(tempTotalDemand); //total demand
		tempTS = calculateTotal(tempTotalSupply); //total supply
		
		pMatchICVector.append(tempIC);
		pMatchCCVector.append(tempCC);
		pMatchEDVector.append(tempED);
		pMatchESVector.append(tempES);
		pMatchTDVector.append(tempTD);
		pMatchTSVector.append(tempTS);
//	}
}
//Draws each card in the deck to the screen.
void Deck::drawDeck(int x, int y, int separation)
{
	calculateTotal();

	//Draw each card in the deck.
	for (unsigned int i = 0; i < m_myDeck.size(); i++)
	{
		m_myDeck[i]->getSprite().setPosition((float)x + i*separation, (float)y);
		Game::instance().getWindow().draw(m_myDeck[i]->getSprite());
	}

	//Check if deck is not empty.
	if (m_myDeck.size() != 0)
	{
		//Draw the rectangle and the value of the card inside it.
		m_valueRect.setPosition((float)x - 44, (float)y);

		//Center text on button.
		m_totalText.setOrigin(m_totalText.getLocalBounds().left + m_totalText.getLocalBounds().width / 2, m_totalText.getLocalBounds().top + m_totalText.getLocalBounds().height / 2);
		m_totalText.setPosition(m_valueRect.getPosition().x + m_valueRect.getLocalBounds().width / 2, m_valueRect.getPosition().y + m_valueRect.getLocalBounds().height / 2);

		Game::instance().getWindow().draw(m_valueRect);
		Game::instance().getWindow().draw(m_totalText);
	}
}
Exemple #3
0
int main()
{
	int total = calculateTotal(2,7,7);
	printf("Total > %d\n",total);
	
	return 0;
}
// Function:     processSale
// Inputs:       NA
// Outputs:      NA
// Description:  Calculates totals and taxes.
//
void ContractorSale::processSale()
{
    // Calculate subtotal.
    calculateSubTotal();
    double subtotal = getSubTotal();

    std::cout << SUBTOTAL << subtotal << std::endl;
    std::cout << SALE_CONT << std::endl;
    std::cout << CONT_ID;

    // Prompt for user id.
    getline(std::cin, contractorID);

    int attempts = 0;

    while ( contractorID.compare(OVERIDE) != 0 && (contractorID.length() > MAX_ID_LENGTH || contractorID.length() < MIN_ID_LENGTH || !file.lookupID(contractorID)) )
    {
        attempts++;

        // ID too long
        if ( contractorID.length() > MAX_ID_LENGTH )
        {
            std::cout << ERROR_ID_TOO_LONG << std::endl;
        }
        // ID too short
        else if ( contractorID.length() < MIN_ID_LENGTH )
        {
            std::cout << ERROR_ID_TOO_SHORT << std::endl;
        }
        // ID not found in file
        else if ( !file.lookupID(contractorID) )
        {
            std::cout << ERROR_ID_NOT_FOUND << std::endl;
        }

        // Notify that can overide after 3 attempts.
        if ( attempts > 2 )
        {
            std::cout << CAN_OVERIDE << std::endl;
        }

        // Prompt for user id.
        std::cout << std::endl;
        std::cout << CONT_ID;
        getline(std::cin, contractorID);
    }

    applyDiscount();

    std::cout << DISCOUNT << OPEN_PERC << getDiscount()*100 << CLOSE_PERC << getAmtDiscounted() << std::endl;
    std::cout << SUBTOTAL << getSubTotal() << std::endl;

    calculateTax();
    calculateTotal();

    std::cout << TAX << OPEN_PERC << getTaxRate()*100 << CLOSE_PERC << getTotalTax() << std::endl;
    std::cout << TOTAL_AMT << getTotalAmt() << std::endl;
}
Exemple #5
0
void LaminatTask::calculateSize()
{
    if (!ui->checkGroup->isChecked()){
        return;
    }
    size = sizeW->getSize();
    ui->size->setText(size.toString());
    calculateTotal();
}
Exemple #6
0
void LaminatTask::initWidget(Stock *stock)
{
    if (stock == NULL) {
        return;
    }
    size = sizeW->getSize();
    ui->size->setText(size.toString());
    ui->stockInfo->stockChanged(stock);
    loadStockVar(stock);
    calculatePrice();
    calculateTotal();
}