float get_item() //Getting information on the items.
{
char item [20];
float price;
float quantity;
float cost;
cout << "Enter the item name: ";
cin >> item;
do {
cout << "Enter the items price: $";
cin >> price;
if (price < 0)
{
cout << "Prices cannot be negative, please enter a valid price." << endl;
}
}
while (price <0);
do {
cout << "Enter the quantity you want to purchase: ";
cin >> quantity;
if (quantity <0)
{
cout << "Item quantity cannot be negative, please enter a valid amount." << endl;
}
cost=price*quantity; // This is what I want to send, cost.
}
while (quantity <0);
}
float get_discount() //Getting information on the discount.
{
float discount;
float dcost; // I need cost to be here as dcost, is that possible?
do {
cout << "Enter percent discount here: %";
cin >> discount;
if (discount < 0)
{
cout << "Discount cannot be negative, please enter a valid discount." << endl;
}
discount = (discount * 0.01f);
}
while (discount <0);
}
Can you show me how to do that please? I have been trying for so long but I keep typing it up wrong or something and I get errors! All week I have been stuck here!
Oh man ... I think I messed this assignment up. Cause in my first function nothing is getting done to "mynumber" all I wanted was to get the cost variable down to the next one.