if (result != null && result.getCampaignEstimates() != null) {
KeywordEstimate[] keywordEstimates =
result.getCampaignEstimates()[0].getAdGroupEstimates()[0].getKeywordEstimates();
for (int i = 0; i < keywordEstimates.length; i++) {
Keyword keyword = keywordEstimateRequests.get(i).getKeyword();
KeywordEstimate keywordEstimate = keywordEstimates[i];
if (Boolean.TRUE.equals(keywordEstimateRequests.get(i).getIsNegative())) {
continue;
}
// Find the mean of the min and max values.
double meanAverageCpc =
(keywordEstimate.getMin().getAverageCpc().getMicroAmount() + keywordEstimate.getMax()
.getAverageCpc().getMicroAmount()) / 2.0;
double meanAveragePosition =
(keywordEstimate.getMin().getAveragePosition() + keywordEstimate.getMax()
.getAveragePosition()) / 2.0;
double meanClicks =
(keywordEstimate.getMin().getClicksPerDay() + keywordEstimate.getMax()
.getClicksPerDay()) / 2.0;
double meanTotalCost =
(keywordEstimate.getMin().getTotalCost().getMicroAmount() + keywordEstimate.getMax()
.getTotalCost().getMicroAmount()) / 2.0;
System.out.printf("Results for the keyword with text \'%s\' and match type \'%s\':%n",
keyword.getText(), keyword.getMatchType());
System.out.printf("\tEstimated average CPC: %.2f\n", meanAverageCpc);