• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

How can I pull input from one var to another?

 
Greenhorn
Posts: 3
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I pull the input from a variable to display the totalMinutes without disrupting the calculation in the following program? Any assistance would be greatly appreciated, because I'm stumped.
 
Ranch Foreman
Posts: 295
4
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you elaborate more? What did you mean by pull the input from a variable ?
 
Marshal
Posts: 64618
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

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.
 
Justin Long
Greenhorn
Posts: 3
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Justin Long
Greenhorn
Posts: 3
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Campbell Ritchie the option panes are something we just covered so I'm limited to what I can use to complete the assignment. Thanks to my dinosaur textbook.  
 
Campbell Ritchie
Marshal
Posts: 64618
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?
 
Marshal
Posts: 24586
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Paul Clapham
Marshal
Posts: 24586
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:

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.
 
Campbell Ritchie
Marshal
Posts: 64618
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!