1. LOL I made a very stupid mistake there. Thank you guys again for helping me. I will let you know how the program turns out.

-Nick

2. Ok I know what you could do within your math, dont need to use if I belive. You want to make it so for ever orange you buy it makes the total lower right? Why not do this?
1st you need to make 4 ints: int a, int b, int c, and int d.
2nd make int a apples, int b oranges, and int c and d nothing atm.
3rd you want to know how meny oranges would take off on apples no? Then take int b - int a that would = how meny apples they will have to buy. This will be int c, make that look like this
Code:
`c = b-a;`
4th now take int c times lets say 1.50 (this is how much the apples cost alone)
Code:
`c = c*1.50;`
5th now we will do the same to b
Code:
`b = b*1.50;`
Code:
`d = b+c;`
8th just show what d = to and thats your totall prise. I didnt even need to use the if half. Hope that helps you.

3. I am having another probelem now lol. When the program prints the total it prints it like this 140 and I need it to print like this 14.00. It might be the variable types but I have changed them from int to double to float and there has been no change.

-Nick

4. WAIT! forget everything I saidXD Will ok not everything. Ok in my code I found a little a problem... ok thos ints I told you to make, trun them into float like so...
Code:
`float a;`
Also change step 3 code to
Code:
`c = a-b;`
Heres what ints, long, bla bla can do with numbers.

int: used to store integers (whole numbers, no decimals/fractions)
long: used to store larger integers
double: used to store numbers with two decimal places
float: used to store numbers with multiple decimal places
char: used to store a single character

This is why you need to learn math kids So you dont have to use the "if" LOL. Best of luck on your work. (I am a kid, I was just playing)

5. I changed the variables that would use float to float but nothing happened, So then I changed them all to float and its still not working. This is very strange. LOL I am basically done with the program with one more little hurdle to jump and its the worst one. Do you guys see anything causing this that I don't see in this code?

Code:
```#include <cstdlib>
#include <iostream>
#include <string>
#include <conio.h>

using namespace std;

float orange (int firsta);//orange prototype.
float apple (int firstb);//apple prototype.
int main()
{
//vars
int usra,usro;                  //Users choice of apples. Users choice of Oranges.
float applecal, orangecal;      //Apple calculations. Orange calculations.
float result, resultd;          //The final result. The result of the discount.
//vars end
//sig
cout<<"*********************************************************"<<endl;
cout<<"*                                                       *"<<endl;
cout<<"*              Nicks Grocery store                      *"<<endl;
cout<<"*                                                       *"<<endl;
cout<<"*********************************************************"<<endl;
cout<<endl;
//sig end
//Program
cout<<"Welcome to Nick's Grocery Store."<<endl;
cout<<endl;
cout<<"****Todays Specials.*****"<<endl;
cout<<"*Buy one Apple get one  *"<<endl;
cout<<"*free!                  *"<<endl;
cout<<"*-----------------------*"<<endl;
cout<<"*bill.                  *"<<endl;
cout<<"*************************"<<endl;
cout<<"Max of 100 items per customer"<<endl;
cout<<"*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*"<<endl;
cout<<endl;

cout<<endl;

//Asks how many Apples the User wants.
cout<<"How many Apples would you like "<<username<<" :";
cin>>usra;
cout<<endl;

//Asks how many Oranges the User wants.
cout<<"How many Oranges would you like "<<username<<" :";
cin>>usro;
cout<<endl;
cout<<"*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*"<<endl;

applecal= apple(usra);//Calling the apple function/
orangecal= orange(usro);//Calling the orange function.

resultd= 100/usro*addao;//Finds the amount of money you have saved.

result= resultd-=addao;//Deducts the amount you have saved from the total.

cout<<endl;

getch();
return 0;

//Program end
}
//Math for Apples
float apple(int firsta)
{
return firsta/2+firsta%2;
}
//Math for Oranges
float orange(int firstb)
{
return firstb*1.50;
}```

resultd= 100/usro*addao;//Finds the amount of money you have saved.
cout << resultd << endl;
result= resultd-=addao;//Deducts the amount you have saved from the total.
cout << result << " " << resultd << " " << addao << end;

Figure it out, do some debugging.

The last expression looks very odd indeed.

7. Here is how I showed it, its just a sample, hope it helps.
Code:
```#include <iostream>

using namespace std;

float a;
float b;
float c;
float d;

int main(){
cout << "Enter a number: ";
cin >> a;
cout << "Enter a second number: ";
cin >> b;

c = a-b;
c = c*1.50;
b = b*1.50;
d = c+b;

cout << "The sum is: " << d;

system("pause");

}```

8. Can anyone help me with getting this program to display the total price correctly. It is displaying like this 144 but I want to to display this 14.40.

-Nick

Code:
```#include <cstdlib>
#include <iostream>
#include <string>
#include <conio.h>

using namespace std;
//prototypes
float applecal(int);//Applecal function.
float orangecal(int);//Orangecal function.
//
int main()
{
//text and background color
system("color 8F");
//text and background color end
////////////////////////////////////////////////////////////////////////////////
//vars
int usro , usra;            //The users choice of apples and oranges.
float usrac , usroc;        //The calculated results of the users input.
float add , result;         //Adding both usrac and usroc together. Main result.

//vars end
////////////////////////////////////////////////////////////////////////////////
//sig
cout<<"             -*********************************************************-"<<endl;
cout<<"             **                                                       **"<<endl;
cout<<"           ****              Nicks store                              ****"<<endl;
cout<<"             **                                                       **"<<endl;
cout<<"             -*********************************************************-"<<endl;
cout<<endl;
//sig end
////////////////////////////////////////////////////////////////////////////////
//Program
cout<<"Welcome to Nick's Store."<<endl;
cout<<endl;
cout<<"****Todays Specials.*****"<<endl;
cout<<"*Buy one Apple get one  *"<<endl;
cout<<"*free!                  *"<<endl;
cout<<"*-----------------------*"<<endl;
cout<<"*bill.                  *"<<endl;
cout<<"*************************"<<endl;
cout<<"Max of 100 items per customer"<<endl;
cout<<"*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*"<<endl;
cout<<endl;

//Asks how many Apples the User wants.
cout<<"How many Apples would you like :";
cin>>usra;
cout<<endl;
applecal(usra);//calling applecal function.
usrac=applecal(usra);//getting USRA variable data from applecal.

//Asks how many Oranges the User wants.
cout<<"How many Oranges would you like :";
cin>>usro;
cout<<endl;
orangecal(usro);//calling orangecal function.
usroc=orangecal(usro);//getting USRO variable data from orangecal.

cout<<"*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*"<<endl;
cout<<endl;

//end program
getch();
return 0;
}
////////////////////////////////////////////////////////////////////////////////

//applecal function.
float applecal(int first)
{
return first/2*1.00+first%2;
}
////////////////////////////////////////////////////////////////////////////////

//orangecal function.
float orangecal(int first)
{
return first*1.50;
}
////////////////////////////////////////////////////////////////////////////////```

9. ternary operator to the rescue.
Code:
`delivered=(type==APPLE?number*2:number);`
Maybe not in the spirit of the assignment, but who cares

10. Why do schools like assigning such asinine programming homework?

11. Originally Posted by jwenting
ternary operator to the rescue.
Code:
`delivered=(type==APPLE?number*2:number);`
Maybe not in the spirit of the assignment, but who cares
lol thanks for the reply but I cant use anything I havent learnt yet. my teacher told me to try deviding the end resuly by 100.00, I get the correct answer and the decemals are in the right place when I do it but it still isnt displaying that extra 0 there. I think it is doing it because the 0s would just keep going and going and going if it had to display them. Is there a way I can get it to just display the last zero like this 14.40 instead of this 14.4.

-Nick

12. can you use setprecision

13. Originally Posted by Syneris
can you use setprecision
I just gave it a try but it still isnt showing that extra 0. I am clueless. Anyone else know whats going on with my program?

-Nick

14. Originally Posted by Nick_365
I am having another probelem now lol. When the program prints the total it prints it like this 140 and I need it to print like this 14.00. It might be the variable types but I have changed them from int to double to float and there has been no change.