### 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

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798`` ``````#include #include #include 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:

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201`` `````` 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!

 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.