Not Sure what she is doing!

I am suppose to write a program that reads the number each meal ordered:
Breakfast Cost Each:$5.50, Discount10% If order more than 10
lunch costeach:&9.50 Discount 15% if order more than 15
Dinner cost each: $16.50, Discount 12%if order more than: 8
Write a C++ Program that reads the number each meal ordered . Then do the computations and print results.

This is the program I wrote:

#include <iostream>
#include <iomanip>
using namespace std;

double calcDiscount(int quantity, double costEach, double discountPerCent, int orderMoreThan);

int main()
{
double calcDiscount(int quantity, double costEach, double discountPerCent, int orderMoreThan);

int quantityOfbreakfastOrdered, quantityOflunchOrdered, quantityOfdinnerOrdered;
double cost breakfastcostEach=0.10, lunchcostEach=0.15, dinnercostEach=0.08;
double cost breakfastdiscountPerCent=5.50, lunchdiscountPerCent=9.50, dinnerPerCent=16.50;
int cost breakfastorderMoreThan=10, lunchorderMoreThan=15, dinnerorderMoreThan=8;

cout<<"Enter the Number Of Breakfasts: "<<endl;
cin>>quantityOfbreakfastOrdered;

cout<<"Enter the Number of Lunches "<<endl;
cin>>quantityOflunchOrdered;

cout<<"Enter the Number of Dinners: "<<endl;
cin>>quantityOfdinnerOrdered;

double calcDiscount (int quantity, double costEach, double discountPerCent, int orderMoreThan
{
if(quantity> orderMoreThan)
return discount=0;
if(quantity< orderMoreThan)
return discount=(quantity*costEach)*discountPerCent;
)
void print()
{
cout<<calcDiscount( quantityofbreakfastoOrdered, breakfastcostEach, breakfastdiscountPerCent, breakfastorderMoreThan)<<endl;
cout<<calcDiscount(quantityoflunchOrdered, lunchcostEach, lunchdiscountPerCent, lunchorderMoreThan)<<endl;
cout<<calcDiscount(quantityofdinnerOrdered, dinnercostEach, dinnerdiscountPerCent, dinnerorderMoreThan)<<endl;
}
return 0;
}

I have completely messed this up I think. If anyone can help please!
it is very nice idea let me do a strategy for it
I'm sorry I just noticed the assignment got cut off:
Programming Assignment 4
A catering service has the following schedule of charges for meals that it serves to groups and discounts according to how many were ordered:

Meal Cost Each Discount If order more than
Breakfast $5.50 10% 10
Lunch $9.50 15% 15
Dinner $16.50 12% 8

Write a C++ program that reads the number of each meal ordered. Then do the computations and print results as indicated below. The program should compute, for each category, the cost of the meals received in each category, the discount, and the final cost of the meals. It should then compute the total cost of all meals, add a 10% sates tax and print the total due. Be sure to format the output. No loop is necessary.

Make your output attractive and include appropriate comments in your program. Below is an example of what the inputs and output of the program should look like.

For each meal, Cost Each, Discount, and If order more than should be constants. The calculation of the discount HAS to be done in a function. There should be only 1 function to calculate all three different meal types. The function prototype will look like this:

double calcDiscount (int quantity, double costEach, double discountPerCent, int orderMoreThan);

Enter the number of Breakfasts ordered: 30
Enter the number of Lunches ordered: 28
Enter the number of Dinners ordered: 25
My Favorite Catering Service
***********************************************
Meal Quantity Cost Discount Cost After Discount
Breakfast 30 165.00 16.50 148.50
Lunch 28 266.00 39.90 226.10
Dinner 25 412.50 49.50 363.00

Total 737.60
Sales Tax 73.76
Total Due 811.36


what do you mean do a strategy?
Initially I wasn't going to help you; this is your assignment, and you should have some idea how to go about it. But then I read your code, and it became clear that you do not have the faintest idea what you've done. In short, this is a catastrophe. I'm not going to do your assignment for you, but here are some tips. You will have to try to sort them out as best you can, and post your results before I will offer any additional help. Sincerely, juanita4545, I must tell you that programming is not for everyone, and you may be among that population. I'm not trying to be mean to you, but frankly, your code demonstrates almost no understanding of the material.

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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <iostream>
#include <iomanip>
using namespace std;

// this is okay
double calcDiscount(int quantity, double costEach, double discountPerCent, int orderMoreThan);

int main()
{
// this is in the wrong place - it's a function prototype, not a variable
double calcDiscount(int quantity, double costEach, double discountPerCent, int orderMoreThan);

// instead of using individual variables, you can use an array for each of these
// int quantity[3];
// then in your program, you can refer each index as a meal
// so 0 would be breakfast, 1 would be lunch, and 2 would be dinner
// then do the same for cost, and discount, and discount cap
// you can then use a loop to call your calcDiscount function
// using the index of the arrays as the formal parameters

// nevermind -- too confusing, I'm sure

// you also have your costs and discounts confused
// and have declared variable "cost" three times
// and you don't need it, really.
int quantityOfbreakfastOrdered, quantityOflunchOrdered, quantityOfdinnerOrdered;
double cost breakfastcostEach=0.10, lunchcostEach=0.15, dinnercostEach=0.08;
double cost breakfastdiscountPerCent=5.50, lunchdiscountPerCent=9.50, dinnerPerCent=16.50;
int cost breakfastorderMoreThan=10, lunchorderMoreThan=15, dinnerorderMoreThan=8;

cout<<"Enter the Number Of Breakfasts: "<<endl;
cin>>quantityOfbreakfastOrdered;

cout<<"Enter the Number of Lunches "<<endl;
cin>>quantityOflunchOrdered;

cout<<"Enter the Number of Dinners: "<<endl;
cin>>quantityOfdinnerOrdered;

// your variables are local; you have to call your calcDiscount
// function from within main(), so all that stuff you have in
// your print() function needs to go here instead.


// then, you need to do all of your output display as per your assignment

// then, you need to end your main() function
// **HERE**

// you need a closing parenthesis at the end of this
double calcDiscount (int quantity, double costEach, double discountPerCent, int orderMoreThan
{
if(quantity> orderMoreThan) // you've got your less than < and greater than > confused

 // you don't want to return here... you want to perform your calculation the same way
 // but without applying the discount. Calculate the discount based on your logic (but
 // switch your < and >). If they didn't order enough to get a discount, then don't use
 // your discount multiplier to reduce the cost.

return discount=0; // you need to declare a discount variable before using it.

if(quantity< orderMoreThan) // other way around

// in both cases, you want to start with (quantity*costEach)
// but if there is a discount, you want to apply the discount first
return discount=(quantity*costEach)*discountPerCent;
)

// this print function is unnecessary
void print()
{
// since you need to keep a running total, you can't simply output these values
// you need to store the return value, and add to it each time you call the
// calcDiscount function
// here is an idea to get you started, but in the main() function, not in this weird print function:
// double total = 0.0;
// total+=calcDiscount(quantityofbreakfastoOrdered, breakfastcostEach, breakfastdiscountPerCent, breakfastorderMoreThan)
cout<<calcDiscount( quantityofbreakfastoOrdered, breakfastcostEach, breakfastdiscountPerCent, breakfastorderMoreThan)<<endl;
cout<<calcDiscount(quantityoflunchOrdered, lunchcostEach, lunchdiscountPerCent, lunchorderMoreThan)<<endl;
cout<<calcDiscount(quantityofdinnerOrdered, dinnercostEach, dinnerdiscountPerCent, dinnerorderMoreThan)<<endl;
}
return 0;  // this needs to go where **HERE** is
} // followed by this 
Thanks for being a jerk about it.
There are a lot of other jerks who didn't bother to help you at all. When evaluating someone's understanding of concepts, there is no place for the saying, "If you don't have something nice to say, don't say anything at all" because that sort of dishonesty by omission is not going to help you learn C++.

I really do want to help you, or I wouldn't have taken the time to comment on your code, and try to show you where you needed to make changes or improvements to get things heading in the right direction. You don't have to accept my offer of assistance, but don't refuse it just because you didn't like my appraisal of the situation.
Topic archived. No new replies allowed.