C++ homework Due 3-19-2012 Tues. Morning

Hello to all the C++ experts I am taking a beginner C++ class using Quincy. I will be forever gracious if anybody can answer these for me this is an important homework assignment due Tuesday morning (3-19-2013). I have been up for hours trying to figure these out but I keep getting a message Unsuccessful build. To all who know this is probably easy, but I am having a very difficult time with this.



1. A company has an unknown number of employees. The company decided to help employees to overcome their budgeting problem as follows:

Each employee gets extra money based on the age of their dependents, if age of child is less than six, company pays $50 for each year of the child age, if age of child is less than ten, company pays $30 for each of the child age, otherwise company pays $20 for each child over ten. Write a C++ program that prints each employee’s name, number of child/children and at end of program print total extra money company paid to the employees.




2. Write a program for a grocery store that pays $50 discount to the first ten customers who purchases more than $200 and pays $5 discount to next other customers. Program should print each customer total after discount and total discount amount of discount gain also total number of customers.



3. A bookstore has 3000 copies of books each book has a discount as follows: If book price is more than $60, customers get 20% discount, if book price is more than $40 and less than $60 customer get 10% discount. If total price is more than $200, customer receives an additional 5% discount. Write a C++ program that calculates and prints each customer total after discount, if it applies. Total number of customer who gets 20%, 10% and total number of customers who got an extra 5% on their total.
I have been up for hours trying to figure these out but I keep getting a message Unsuccessful build.


Above "unsuccessful build" it will list various errors. You can double click on the error and it'll jump to the exact line that the error is on.

If you tell us what the actual errors are, and show us the code generating them, we can help you resolve the errors.

But we're not going to do the work for you.
Lol Disch, Help him out a bit.
closed account (Dy7SLyTq)
@greenleaf: how do you purpose he does that. he cant write it for him cause its homework and disch has no code to go off of or errors
Lol Disch, Help him out a bit.


I told him what I could about reading and interpretting the error messages he's getting.

Apart from that:

1) He didn't ask a question, so there is nothing I can directly answer

2) The assignments he posted already give a basic idea of what needs to be done.


I don't see how I could have done more than I did without just doing all the work for him.


EDIT: Besides... waiting until the night before it's due to write 3 full programs? I almost didn't reply at all.
Last edited on
I saw this post like a week ago. I understand his question enough. Besides a little practice is nothing.
One small bug in library though, pricing

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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

class factory // Class for factory scenario
{
public:
    char Employee[256];
    string EmChild[128]; // Child Name  { array because of the possibility of}
    int EmChAge[128]; // Child Age      { multiple children                  }
    int discount;
};

class grocery // Class for shopping scenario
{
public:
    char Customer[256];
    double PriceTag; // Sub-Total
    double FPriceTag; // Final Price
    int Discount;
};

class library // Class for Library scenario
{
public:
    char Customer[256];
    double PriceTag;
    double FPriceTag;
    double Discount;
    char BookName[256]; // Multiple books
    double BookPrice[256];
    int books;
    int Discount_F,Discount_S,Discount_B;
};

void factoryCalc()
{
    factory Discounts[1024];
    int children,ChildAge,I = 0;
    char ChildName[256];
    string EmName;

    for(int i = 0;i < 1024;i++)
    {
        cout << "Enter employee name: ";
        cin.getline(Discounts[i].Employee,256);
        cin.getline(Discounts[i].Employee,256);
        EmName = Discounts[i].Employee;

        if(EmName == "Quit") // To quit
        {
            break;
        }

        cout << "Enter number of children: ";
        cin >> children;
        for(int j = 0;j < children;j++)
        {
            cout << "Enter child " << j + 1 << "'s name: " << endl;
            cin.getline(ChildName,256);
            cin.getline(ChildName,256);
            Discounts[i].EmChild[j] = ChildName;
            cout << "Enter child " << j + 1 << "'s age: " << endl;
            cin >> ChildAge;
            Discounts[i].EmChAge[j] = ChildAge;
            if(ChildAge < 6)
            {
                Discounts[i].discount += 50;
            }
            else if(ChildAge < 10 && ChildAge > 6)
            {
                Discounts[i].discount += 30;
            }
            else
            {
                Discounts[i].discount += 20;
            }
        }
        I++;
    }

    cout << endl << endl;

    for(int i = 0;i < I;i++)
    {
        cout << "Employee Name: " << Discounts[i].Employee << endl;
        cout << "Number Of Children: " << children << endl;
        for(int j = 0;j < children;j++)
        {
            cout << "Child " << j + 1 << ": " << Discounts[i].EmChild[j] << endl;
            cout << "Age: " << Discounts[i].EmChAge[j] << endl;
        }
        cout << Discounts[i].Employee << "'s discount: $" << Discounts[i].discount << endl;
        cout << "-----------------------------------" << endl;
    }
    cout << endl << endl;
}
continued:

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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201

void groceriesCalc()
{
    grocery Customers[1024];
    int T = 0;
    int TotalDiscount = 0;
    string customer;

    for(int i = 0;i < 1024;i++)
    {
        cout << "Enter Customer " << i + 1 << "'s name: ";
        cin.getline(Customers[i].Customer,256);
        cin.getline(Customers[i].Customer,256);
        customer = Customers[i].Customer;

        if(customer == "Quit")
        {
            break;
        }

        cout << "Enter final price tag: $";
        cin >> Customers[i].PriceTag;

        if(i < 10 && Customers[i].PriceTag > 200)
        {
            Customers[i].Discount += 50;
            TotalDiscount += 50;
        }
        else if(Customers[i].PriceTag > 200)
        {
            Customers[i].Discount += 5;
            TotalDiscount += 5;
        }

        T++;
    }

    cout << endl << endl;

    for(int i = 0;i < T;i++)
    {
        cout << "Customer " << i + 1 << "'s name: " << Customers[i].Customer << endl;
        cout << "Customer Sub-Total: $" << Customers[i].PriceTag << endl;
        cout << "Customer Discount: $" << Customers[i].Discount << endl;
        Customers[i].FPriceTag = Customers[i].PriceTag - Customers[i].Discount;
        cout << "Customer Total: $" << Customers[i].FPriceTag << endl;
        cout << "--------------------------------------------" << endl;
    }

    cout << "Store's expense on discounts: $" << TotalDiscount << endl;
}

void libraryCalc()
{
    library Browser[256];
    int Discount_F = 0,Discount_S = 0,Discount_B = 0,B = 0,C = 0; // $40 and $60 Discounts and the bonus %5. Number of Books sold and Customers
    double temp = 0;
    double total = 0;
    string customer;
    char ttemp[256];

    for(int i = 0;i < 256;i++)
    {
        cout << "Customer " << i + 1 << "'s Name: ";
        cin.getline(Browser[i].Customer,256);
        cin.getline(Browser[i].Customer,256);
        customer = Browser[i].Customer;

        if(customer == "Quit")
        {
            break;
        }

        cout << "Enter a negative in book price to quit." << endl;

        for(int j = 0;j < 256;j++)
        {
            cout << "Enter book " << j + 1 << "'s title: ";
            cin.getline(ttemp,256);
            if(j > 0)
            {
                cin.getline(ttemp,256);
            }
            Browser[i].BookName[j] = *ttemp;

            cout << "Enter book price: ";
            cin >> Browser[i].BookPrice[j];

            if(Browser[i].BookPrice[j] < 0)
            {
                break;
            }

            if(Browser[i].BookPrice[j] > 60) // $60 discounts
            {
                temp = Browser[i].BookPrice[j] * 0.2;
                Browser[i].Discount += (Browser[i].BookPrice[j] - temp);
                total += Browser[i].Discount;
                Browser[i].Discount_S++;
                Discount_S++;
            }
            else if(Browser[i].BookPrice[j] > 40 && Browser[i].BookPrice[j] < 60) //$40 Discounts
            {
                temp = Browser[i].BookPrice[j] * 0.1;
                Browser[i].Discount += (Browser[i].BookPrice[j] - temp);
                total += Browser[i].Discount;
                Browser[i].Discount_F++;
                Discount_F++;
            }

            Browser[i].PriceTag += Browser[i].BookPrice[j];
            B++;
        }

        if(Browser[i].PriceTag > 200)
        {
            temp = Browser[i].PriceTag * .05;
            Browser[i].FPriceTag = temp;
            total += (Browser[i].PriceTag - temp);
            Browser[i].Discount_S++;
            Discount_S++;
        }
        else
        {
            Browser[i].FPriceTag = Browser[i].PriceTag;
        }

        Browser[i].books++;
        C++;
    }

    cout << endl << endl;

    for(int i = 0;i < C;i++)
    {
        cout << "Customer " << i + 1 << "'s name is: " << Browser[i].Customer << endl;
        cout << Browser[i].Customer << " bought " << Browser[i].books << " books!" << endl;
        for(int j = 0;j < Browser[i].books;j++)
        {
            cout << Browser[i].BookName[j] << "\t" << "$" << Browser[i].BookPrice << endl;
        }
        cout << "Amount of $60 discounts: " << Browser[i].Discount_S << endl;
        cout << "Amount of $40 discounts: " << Browser[i].Discount_F << endl;
        cout << "Amount of bonus > $200 discounts: " << Browser[i].Discount_B << endl;
        cout << "Sub-Total: $" << Browser[i].PriceTag << endl;
        cout << "Total Discounts: $" << Browser[i].Discount << endl;
        cout << "Total: $" << Browser[i].FPriceTag << endl;
        cout << "----------------------------------------------------" << endl;
    }

    cout << endl << "Amount of people with $60 discounts: " << Discount_S << endl;
    cout << "Amount of people with $40 discounts: " << Discount_F << endl;
    cout << "Amount of people with bonus discounts: " << Discount_B << endl;
    cout << "Number of books sold today: " << B << endl;
    cout << "Store's expenses on discounts: $" << total << endl;
}

int main(int nNumberofArgs,char* pszArgs[])
{
    char answer;

    cout << "Welcome to the multi-tasking discount machine!" << endl;

    for(;;)
    {
        cout << "F for Factory scenario, G for Groceries scenario, and L for Library scenario" << endl;
        cout << "Enter Q to quit: ";
        cin >> answer;

        switch(answer)
        {
        case 'f':
        case 'F':
            cout << "Enter 'Quit' to quit" << endl;
            factoryCalc();
            cout << endl;
            break;
        case 'g':
        case 'G':
            cout << "Enter 'Quit' to quit" << endl;
            groceriesCalc();
            cout << endl;
            break;
        case 'l':
        case 'L':
            cout << "Enter 'Quit' to quit" << endl;
            libraryCalc();
            cout << endl;
            break;
        case 'q':
        case 'Q':
            cout << "Thank you for using this application, have a nice day!" << endl;
            system("PAUSE");
            return 0;
        default:
            cout << "Please enter 'F','G', or 'L'" << endl;
        }
    }
    return 0;
}
closed account (Dy7SLyTq)
OH MY GOD!!! GREENLEAF YOU CANT DO HOMEWORK FOR SOMEONE ELSE!

[edit] w/o making a profit first
Last edited on
It's not against the rules or anything, but it is rather depressing.

I'd rather not see this forum turn into a homework service for people too lazy to do the work themselves.

I'm very disappointed, greenleaf. Giving away solutions doesn't help anyone. His failure to be able to do this task just means he's going to be ill prepared for the next one. Will you give him the solution for that one as well? Why not just take the course for him?


I'm tempted to report in order to remove the post... but since it's technically not against the rules....
closed account (Dy7SLyTq)
actually i think it is against the rules
I can't even find a copy of the rules.
closed account (Dy7SLyTq)
my mistake it was guidelines in the beginner section
- These programs only require a basic understanding and knowledge of C++ and arithmetic. I don't really understand the issue, and the only advice i can give you is to make use of loops and to not wait until the last minute.

- I'll probably laugh if the kid tries to turn in the code that greenleaf gave him, and it ends up not working.
...Bored, too bored.
Topic archived. No new replies allowed.