How to start this program?

This is a homework question I am a complete beginner when it comes to coding and i was wondering you could help me start my code for my assignment.
i have to code an invoice that will come out like this
I just want to know how to start the math portion

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

so far all i have have is this:
#include<iostream>

#include <iomanip>

using namespace std;

int main ()

{
//Heading
cout << "BOB'S FRUITS GROCERY INVOICE\n";
cout <<"---------------------------------------\n";
float apples;
float oranges;
float bananas;

cout<<"How many apples?" << end1;
cin>>apples;
cout << "How many oranges?" << end1;
cin>>oranges;
cout << "How many bananas?" <<end1;
cin >>bananas;

cout<<"---------"
totalcost= apples * APPLE_COST + oranges * ORANGES+COST + bananas * BANANA_COST;

cout << "Your total is:"<< totalcost << end1;



system("PAUSE");
return 0;
}
i vaguely understand how to incorporate the math into the program .
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const double APPLE_COST = 0.65;
const double LESWAF_COST = 831.5;

int apples = 0;
int leswaf = 0;
int totalcost = 0;

cout << "How many apples? "
cin >> apples;
cout << "How many limited edition star wars action figures? "
cin >> leswaf;

totalcost = apples * APPLE_COST + leswaf * LESWAF_COST;

cout << "Your total is: " << totalcost  << endl;

Last edited on
I tried this, It did not work
#include<iostream>

#include <iomanip>

using namespace std;

int main ()

{
//Heading
cout << "BOB'S FRUITS GROCERY INVOICE\n";
cout <<"---------------------------------------\n";

const double APPlE_COST = 0.65;
const double ORANGE_COST =0.90;
const double BANANA _COST = 0.70;

int apples = 0;
int oranges = 0;
int bananas = 0;
int totalcost = 0;

cout<<"How many apples?\n"
cin>>apples;
cout << "How many oranges?\n"
cin>>oranges;
cout << "How many bananas?\n"
cin >>bananas;

totalcost= apples * APPLE_COST + oranges * ORANGES+COST + bananas * BANANA_COST;

cout << "Your total is:"<< totalcost << end1;


system("PAUSE");
return 0;
}



'hw1e.exe': Loaded 'C:\Users\Justin\Desktop\1.5\Debug\hw1e.exe', Symbols loaded.
'hw1e.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'hw1e.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'hw1e.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'hw1e.exe': Loaded 'C:\Windows\SysWOW64\msvcp100d.dll', Symbols loaded.
'hw1e.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.
'hw1e.exe': Loaded 'C:\Windows\SysWOW64\apphelp.dll', Cannot find or open the PDB file
'hw1e.exe': Loaded 'ImageAtBase0x4a880000', Loading disabled by Include/Exclude setting.
'hw1e.exe': Unloaded 'ImageAtBase0x4a880000'
The program '[5616] hw1e.exe: Native' has exited with code 0 (0x0).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include<iostream> 

using namespace std; 

int main () {
     
//Heading
cout << "BOB'S FRUITS GROCERY INVOICE\n"; 
cout <<"---------------------------------------\n"; 

const double APPLE_COST = 0.65;
const double ORANGE_COST =0.90;
const double BANANA_COST = 0.70; 

int apples = 0; 
int oranges = 0; 
int bananas = 0; 
int totalcost = 0; 

cout<<"How many apples?\n";
cin>>apples; 
cout << "How many oranges?\n";
cin>>oranges; 
cout << "How many bananas?\n";
cin >>bananas; 

totalcost= apples * APPLE_COST + oranges * ORANGE_COST + bananas * BANANA_COST; 

cout << "Your total is:"<< totalcost << endl; 


system("PAUSE"); 
return 0; 
}


This does work.
Topic archived. No new replies allowed.