EDIT: Figured out how to properly put code into a post! Should look better now...
I'm back with another question! It could most likely be answered by about 99% of this forum. (Maybe even 99.9%!!)
Here's my problem: I'm trying to make an application that's designed to run once and only once. The scenario is that I'm selling a product, and the program asks the customer how many of said product they want. Based on the amount given, they get a specific discount. (In this case, more than 100 in quantity gives them 50% off, 50-99 is 40%, 20-49 is 30%, 10-19 is 20%, and anything less gets no discount.)
I think I've set everything up correctly except for one main part. The user input. In C++ this equivalent would be "scanf("%i", &desiredQuantity);" or something along those lines. What would it be in Java?
Here's my code. Oh, and if you see room for improvement or other mistakes, please feel free to let me know! It's a simple program, I know. It's just practice. Because I definitely need it.
Thank you for your time!
Carpe diem, because every day is worth living to its fullest.
Hmm, well, basically what I'm aiming for is this: I want to ask the user to input their desired quantity, have the program store it as a variable ("quantity") then compare it to the if/else statements. I know how to do this in C++ but I can't figure it out in Java. I know it must be pretty simple. And it's probably right under my nose! I just can't seem to locate the command that would do that.
And.. you are using the quantity as a int but it was a String..
to make its convertation use Integer.parseInt(String str) method.
The Scanner object can read an int and make its automatically.
Each of their nuggets of wisdom contracted to a sound bite: Joshua Bloch: Write Lots of Code; Chet Haase: Don't Put Your Entire Application in One Method; Masood Mortazavi: Start Simple and Keep Learning; Cay Horstmann: First, Don't Panic
Joined: Dec 30, 2008
Hmm...alright. I'll give it a shot and see what comes up. As always, thanks for the fast help!