Write a C++ program that creates an invoice for a small fruit vendor named “Bob’s Fruits”. The fruit vendor sells three kinds of fruit: oranges, apples, and bananas. Oranges cost .90 each, apples cost .65 each and bananas cost .70 each. For each type of fruit the program should ask the user how many of this type of fruit they would like to purchase (zero is an acceptable answer). After obtaining the purchase information from the user display an invoice on the screen similar to this:

BOB'S FRUITS GROCERY INVOICE
-----------------------------------------------
20 Apples @ 0.65 each = \$ 13.00
20 Oranges @ 0.90 each = \$ 18.00
20 Bananas @ 0.70 each = \$ 14.00
-----------
TOTAL = \$ 45.00

This invoice is an example of the case where a user buys 20 oranges, 20 apples and 20 bananas. Make sure and use symbolic constants where appropriate in your program and make sure to format your numeric output.

will someone help please

## All 4 Replies

Ehh what do you need help with?? Looks like you just copy and pasted your homework assignment. All I see is some simple multiplication and addition. Accompanied by std::cout. Does that help?

it needs to calculate the costs and display in \$ form the total like this:

``````BOB'S FRUITS GROCERY INVOICE
-----------------------------------------------
20 Apples @ 0.65 each = \$ 13.00
20 Oranges @ 0.90 each = \$ 18.00
20 Bananas @ 0.70 each = \$ 14.00
-----------
TOTAL = \$ 45.00
``````

where the user only inputs the quantity of each fruit, and generates the for each fruit and the total for all three on the bottom. im stuck please help.

``````--------------------------------

#include<iostream>

using namespace std;

int main()
{
float num1, num2, num3;
float sum;

// First Formula

cout<<"How many apples would you like to purchase (.65 cents/each): ";
cin >> num1;

cout<<"How many oranges would you lik to purchase (.90 cents/each): ";
cin >> num2;

cout<<"How many bananas would you lik to purchase (.70 cents/each): ";
cin >> num2;

sum = num1 + num2 + num3;
cout << "BOB'S FRUITS GROCERY INVOICE" << endl;
cout << "----------------------------" << endl;
cout << sum << "Apples @ 0.65 each = " << sum << endl << endl;

system ("PAUSE");
return 0;
}
``````

Figure out how you do this in real life on pencil and paper and then turn the equations into code. You need to use the .90, .65, and .70 in some equation somewhere, right?

Think your logic through first, only then the code will follow.
Take this example:
I want to buy 3 Power Ranger Action figures for 3 kids:
-> 2 want Power Ranger Dino Force (@ \$2)
-> 1 wants Power Ranger SPD (@ \$3)
So my bill look like:

``````---------------------------------------
09/19/2010                       17:50
---------------------------------------
Item            Qty    Price     Total
PR Dino Force   x2     \$2     =  \$4
PR Dino SPD     x1     \$3     =  \$3
--------------------------------------
Total Amount (incl. taxes)   =   \$7
--------------------------------------
Have a Nice Day
---------------------------------------``````

Got anything from it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.