This week's book giveaway is in the Reactive Progamming forum. We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line! See this thread for details.
Don't use doubles for money; use integer arithmetic (demnomiate the amount in pence/cents) or what it recommended here (also look at the two links): BigDecimal.
Except for the main method, delete every occurrence of the keyword static. You will have to create an instance in the main() method.
There is a discrepancy between b in line 46 and b in line 48.
Why are you using option panes for keyboard input? That is a very old‑fashioned style of programming.
There are other things you could improve in that program, but do one thing at a time.
In this block of code I want the following output:
Account Num: (#)
Account Type: (Regular or Premium) - Assignment calls to compare "R" & "r" or "P" & "p".
Account Minutes Used: (#) - Regular should show one # and Premium should show day and night number.
Amount Due: (#)
All outputs work except (Account Minutes Used:)
I'm very new to asking for assistance and wasn't aware of how to ask this. Thank you all for the coaching.
In the "R" case you have a dialog which asks for the total minutes (which you call "amount of minutes" and which native English speakers would call "number of minutes"). You would like to assign the result returned by that dialog to the "totalMinutes" variable? Then do that, instead of passing the result directly to the calculateRegBill method.
In the "P" case I believe you want to assign the sum of dayMinutes and nightMinutes to the totalMinutes variable? Then write a line of code which does that and insert that line after you have the numbers you want to sum.
Justin Pj wrote:@Campbell Ritchie the option panes are something we just covered . . . Thanks to my dinosaur textbook.
Have you been told to use option pane? How old is your book?
The alternative to using option panes is to use a Scanner, which as you know is also a big can of worms. Anyway it seems like the option panes are part of Justin's assignment for better or for worse.
posted 4 months ago
Paul Clapham wrote:. . . a Scanner, which . . . is also a big can of worms.
I think it was Winston who gave the best assessment of Scanner for keyboard input. He said it only has partial documentation and there aren't lots of good tutorials. When I started Java®, I was told that people wrote their own input classes, and did so myself, using BuffereReaders. A year later, in Advanced Programming in Java, we were told that the utility classes were no longer necessary, and in the intervening 13½ years I have come to the conclusion that such a utility class is necessary. But I don't think I have enough time nor energy just at the moment to explain any more. Sorry.
OP: If you go through my posts looking for “utility class Scanner” you will find parts of the utillity class, but you won't find the whole thing all in one place. It will take you a long time. Sorry.
If you live in a cold climate and on the grid, incandescent light can use less energy than LED. Tiny ad: