Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com Need help coding for homework -

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 10-12-2007, 12:22 PM PM User | #1 WeezyF.Baby New to the CF scene   Join Date: Oct 2007 Posts: 1 Thanks: 0 Thanked 0 Times in 0 Posts Need help coding for homework - Here is my assignment: Develop a program to generate a pay stub. Here’s an example stub: Name: Doell, Susan Employee id: SDoe0001 Gross Pay: \$ 1099.15 Retire: \$ 87.93 Tax: \$ 141.57 Net Pay: \$ 869.65 The program is to input an employee’s first, last name, and gross pay. The input is in a file. Here’s the input for the above example: Susan Doell 1099.15 The retirement rate is 8%. Note that the retirement amount is subtracted from the gross pay before the tax is computed. The tax rate is 14%. The employee id is the first initial followed by the first three letters of the last name followed by "0001". I think I need to use strings for the employee name part. I am horrible at math, and the arithmetic has me confused as well. My second problem is this: A cider market purchases apples in bags. How much is paid per bag is dependent on the condition of the apples as follows: Condition Price per Bag Good \$12 Fair \$9.50 A program is needed to prompt for and input the condition of a bag of apples and how many bags are to be purchased. The output is the total price. Here’s a sample run: Enter apple condition: Fair Enter how many bags: 4 The total price is \$38.00 Condition Price per Bag Excellent \$14 Good \$12 Fair \$9.50 This program is almost done; here is what i have so far, l; HOWEVER, IT NEEDS A LOOP: #include #include using namespace std; const float EXCELLENT_COST = 14.0; const float GOOD_COST = 12.0; const float FAIR_COST = 9.5; int main() { string condition; int bags; float costPerBag, totalCost; cout.setf(ios::fixed, ios::floatfield); cout.setf(ios::showpoint); cout << "Enter apple condition: "; cin >> condition ; cout << "Enter how many bags: "; cin >> bags; if (condition == ′"Excellent") costPerBag = EXCELLENT_COST; else if (condition == "Good") costPerBag = GOOD_COST; else costPerBag = FAIR_COST; totalCost = costPerBag * bags; cout << "The total price is \$" << setprecision(2) << totalCost << endl; return 0; } I need a loop so that if the user types something different for the apple condition, the program responds with a message that the input is not a valid one. In this case, the program is not to respond with a total price Any help is highly appreciated. Thank you, - WFB.
 10-12-2007, 07:06 PM PM User | #2 WorldEvolution New Coder   Join Date: Oct 2007 Posts: 11 Thanks: 0 Thanked 1 Time in 1 Post I Had To Do This Same Project. Too Bad It's On My School Computer And I'm At Home. Thats Was One Of The First Things My Teacher Made Us Do In Java.
 10-12-2007, 09:18 PM PM User | #3 Inigoesdr Super Moderator     Join Date: Mar 2007 Location: Florida, USA Posts: 3,628 Thanks: 2 Thanked 404 Times in 396 Posts Here is one way: Code: ``` cout << "Enter apple condition: "; cin >> condition; while(condition != "Excellent" && condition != "Good") // whatever you're checking for { cout << "Invalid input" << endl; cout << "Enter apple condition: "; cin >> condition; }``` You may want to force the input to lower/uppercase for case-insensitive comparison. Also it looks like you have an extra character here: Code: `if (condition == `′`"Excellent")`
 10-12-2007, 11:19 PM PM User | #4 WA Administrator   Join Date: Mar 2002 Posts: 2,596 Thanks: 2 Thanked 19 Times in 18 Posts Please read 1.5 on CF's rules page. We can't help people actually do their homework- that's called cheating. If you need help with a certain aspect of your homework, please post the code you're having trouble with, and explain what help you need. But asking people to basically do your assignment is not allowed. __________________ - George - JavaScript Kit- JavaScript tutorials and 400+ scripts! - JavaScript Reference- JavaScript reference you can relate to.
10-12-2007, 11:56 PM   PM User | #5
Inigoesdr
Super Moderator

Join Date: Mar 2007
Location: Florida, USA
Posts: 3,628
Thanks: 2
Thanked 404 Times in 396 Posts
Quote:
 Originally Posted by WA If you need help with a certain aspect of your homework, please post the code you're having trouble with, and explain what help you need. But asking people to basically do your assignment is not allowed.
I think that's what they did. They had already finished most of it, and just wanted help with one part.

 10-13-2007, 12:14 AM PM User | #6 Nightfire Senior Coder     Join Date: Jun 2002 Posts: 4,266 Thanks: 6 Thanked 48 Times in 48 Posts Problem now being, is that the solution is there for anyone that's doing the same class/course. I refuse to do any homework threads at all, as the next person that's too lazy to do anything has the finished script right infront of them and I dislike cheaters __________________ Blue Panda Website Design | 1 Pound Ads | 'ow much? | Coding Geeks
 10-13-2007, 01:37 AM PM User | #7 Inigoesdr Super Moderator     Join Date: Mar 2007 Location: Florida, USA Posts: 3,628 Thanks: 2 Thanked 404 Times in 396 Posts I see your point. If either of you feel that my response is or might be violating any rules, etc. feel free to delete it.

 Bookmarks

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 09:27 PM.