Click here to Skip to main content
15,885,660 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have been trying to write a program for class that takes 4 numbers entered multplies each one by a different price and gives a total for each one. Then I need to get a subtotal of those 4 and add tax to it then give a total price.

[edit]Don't shout! LOST ON ALL THIS is shouting. And not a helpful title.[/edit]
Posted
Updated 11-May-10 10:29am
v2
Comments
Sandeep Mewara 11-May-10 16:32pm    
You don't need to shout (using CAPS all along is shouting!)... further, you told you are all lost... what did you tried in first place?
[no name] 11-May-10 16:39pm    
I didn't type in all caps, but I apologize. I have tried so many things that I dont even know anymore. I have been working on this for over a week now with no progress.
Christian Graus 12-May-10 19:25pm    
If you didn't type it in all caps, why was it in all caps ? Is your computer magic ? A week is too long to spend stuck, you should have spoken to your teacher before, and definitely need to do so now, esp as you should assume he will google his question and find your post.

C++
1.  Prompt the user for :
customer name
number of pounds of each of the four varieties of nuts
2.  Display an output invoice showing:
      the variety (type of nut)
weight (pounds ordered)
cost (cost per pound times number of pounds ordered)

3.  each type should be followed by a subtotal, amount of tax, and total due.

Nut types:
    Cashews         $6.50 per pound
    Macadamia nuts  $7.25 per pound
    In-shell nuts   $2.39 per pound
    Walnuts         $2.79 per pound
Tax rate
    6.75%

Use a named constant for each of the prices and tax rate.

The following is a sample of the output (lines 1-5 are the input prompts and lines 816 are outputs following the calculations necessary)


That is what the assignment is, however, I am new to all this. My instructor expects us to know this already and well I do not. So it kind is like rocket science to me right now. I have the prompts to input but now I need to do the calculations and everything I have tried has not worked yet.
 
Share this answer
 
Comments
Sandeep Mewara 11-May-10 16:39pm    
Well, if your instructor expects you to know, just go ahead and clear it out that its rocket science to you and you know nothing! Asking here, and might be getting it done by someone will just INCREASE the expectation of your instructor and you will prove he was right...
After this, if it comes in your test/exam... what will you do - cheat?
Christian Graus 12-May-10 19:24pm    
Please don't push answer to post more questions. Edit your post. This assignment is an early step in your course. If you can't understand it, either study more, or drop out. If I write this trivial code for you, how do you expect to do the homework that tries to build on the knowledge you're assumed to have gained from doing this one ?
Well, if your instructor expects you to know, just go ahead and clear it out that its rocket science to you and you know nothing! Asking here, and might be getting it done by someone will just INCREASE the expectation of your instructor and you will prove he was right...
After this, if it comes in your test/exam... what will you do - cheat?

Either ask for more time to learn and do it or tell your instructor that you just don't know how to do it and seek for help from him.
 
Share this answer
 
I know what the program is asking and I know how it should be done, but since I have never done this I am lost on it. I got the beginning of the program asking for the customer name and how many pounds of each. I dont know what to do after that. We don't have a test in this class as our final is write a project. I am a hands on learner so seeing it done then taking from that and adding it in my program how I need it implemented is what I would do. Reading the book has been of no help to me and the instructor moves so fast that I am not the only one having a problem with this. I can learn this with the right help, but I don't know where to find that at this moment. I thought it was here, but that seems to be very wrong and I get criticized because I am new to it. Sorry I am not a expert in the field like most of you are. I was just trying to learn and seek the help your telling me to from another source.
 
Share this answer
 
Comments
Sandeep Mewara 11-May-10 17:04pm    
You are not being criticized for coming here, instead you are being told that since you are stuck with it from 7 days (as you say), what have you learnt till now, what have you tried - Show us (Post the part where you are unable to move on). Providing full code base is not considered good based on various reasons, one of them i had already mentioned earlier (that is in best interest of you only!)
So tell us that to start with. Show us what you have so far, and explain where you are stuck. We aren't going to just give you the full code for your homework (that site is called rentacoder, and they charge you) - if we did, how would you learn?

Some clues:
Console.WriteLine outputs to the console so the user can read it.
Console.ReadLine inputs from the user to a string, so you can read it.
Double.Parse converts a string to a floating point number so you can do math on it.
+ adds numbers
* multiplies numbers

That is about all you really need.
You have the algorithm (see my earlier post), you have the methods you need, off you go.

When you reply, either modify your original question, or use the "Add Comment" button to resopond to a specific answer - the author is then sent an email (like this one) to let him know. DONT use the Answer button - further info is not a answer!


PS: I have posted this twice as a comment, but it gets lost each time.
 
Share this answer
 
Okay well I got a zero on the assignment so it doesn't matter, but I still would like to know where I have a mistake. I keep getting an error that says
C++
Error   1   Cannot implicitly convert type 'string' to 'double' L:\CIS170B\Week 2\Devry Nut Shop\Devry Nut Shop\Program.cs  50  29  Devry Nut Shop

I can't figure out what it wants, because it is not defined as a string. They are declared as doubles.

MIDL
Console.Write("Enter customers name: ");
           custName = Convert.ToString(Console.ReadLine());
           Console.WriteLine("\n");                                      //input customer name and how many pounds of each nut they would like
           Console.Write("How many pounds of Cashews? ");
           poundsCashews = Console.ReadLine();
           totalCashews = Convert.ToInt32(poundsCashews);
           Console.Write("How many pounds of Macadamia? ");
           poundsMacadamia = Console.ReadLine();
           totalMacadamia = Convert.ToInt32(poundsMacadamia);
           Console.Write("How many pounds of In-shell? ");
           poundsInShell = Console.ReadLine();
           totalInShell = Convert.ToInt32(poundsInShell);
           Console.Write("How many pounds of Walnuts? ");
           poundsWalnuts = Console.ReadLine();
           totalWalnuts = Convert.ToInt32(poundsWalnuts);
 
Share this answer
 
Comments
Christian Graus 12-May-10 19:44pm    
This is a new question, and you posting it as an answer is a problem. Hard to know what the exact issue is, I'd guess that Console.ReadLine returns a string, not a double. That is true, but I don't know if that's the line. You turned in an assignment that did not compile ? Wow.
So:

0) Set a total to zero.
1) Read in a number.
2) Multiply is by a price.
3) Output it.
4) Add it to the total
5) Repeat 1 .. 4 three more times, using different prices.
6) Add tax to your total.
7) Output the total.
8) Go for beer after all your hard work.

It's not exactly rocket science, is it? :laugh:
 
Share this answer
 
Comments
Sandeep Mewara 11-May-10 16:29pm    
He looks like more of doing step 8 than 0 to 7! ;) Time crunch might had forced him to create account and get it done... Further i bet, he will not be satisfied with your answer and would be seeking *full* code of it!
Sandeep Mewara 11-May-10 16:37pm    
:) ... have a look again to the post you answered, looks like Enquirer needs more help...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900