Quantcast
Viewing latest article 12
Browse Latest Browse All 25

Grocery Store Part 1

I have been trying to troubleshoot, but I can’t figure out why my compiler is printing out:
“An apple costs: $1.49, there are 23 in inventory found in section: F and your customers gave it an average review of 21908%!”

I don’t know why it isn’t making the proper review number available as a conversion from double to int. I am new to coding any solution to this could help. Thank You


int main() {

  int appleQuantity;
  double applePrice = 1.49;
  double appleReview = 82.5;
  int appleReviewDisplay;
  const char appleLocation = 'F';

  appleQuantity = 23;
  appleReview = (int)appleReviewDisplay;
  

// Put all your code above this and if you declare your variables using the given names and types there is no need to change any of the code below.
printf("An apple costs: $%.2f, there are %d in inventory found in section: %c and your customers gave it an average review of %d%%!", applePrice, appleQuantity, appleLocation, appleReviewDisplay);

}

3 posts - 3 participants

Read full topic


Viewing latest article 12
Browse Latest Browse All 25

Trending Articles