• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help with Java Beginner

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have an assignment that asks the following. If someone could give me some guidance it would be much appreciated. The professor only taught us what javax.swing.JOptionPane does but not how to execute it. I have never programmed so I don't even know where to start. The assignment reads:


Create a program that Asks users to enter an estimated dollar amount for monthly restaurant bill. (You can take
users’ input through the console using the Scanner class or through the input dialog box of
the javax.swing.JOptionPane class.)
 Decide the tip amount: Suppose that users usually give 18% tips, calculate the
corresponding tips for the estimated monthly restaurant bill.
 Decide the monthly IRA investment: Add the tips to the monthly restaurant bill and the total
will be the monthly IRA investment.
 Ask users to enter the number of years that they plan to save (invest) in this way. Again, you
can take users’ input through the console using the Scanner class or through the input
dialog box of the javax.swing.JOptionPane class.

This is the only part of the assignment I cannot figure out. We have a portion for Future Value but she taught that better. Thanks.
 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Daniel, welcome to Java Ranch!

You say you've never programmed before, so does that mean you don't know how to compile and execute Java code? If that's the case, then this assignment is definitely too hard for you. You will have to build up to it. A good place to start is the Java Tutorials page maintained by Oracle. You could run through the first three or four of them, then jump ahead to the one on Swing.
 
Daniel Sheppard
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The issue with the tutorial links you sent me is that they show something called JFrame. Are professor never taught us this option and told me that the whole thing must be completed within the source screen. My mind is literally blown because we were just taught this today:

public class Main {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}

I don't see how one goes from this to that assignment.... do you?
 
Greg Charles
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All your Swing components will be contained by a JFrame, so that's where you have to start. I agree it's a big leap to go from a "Hello, World" program to a GUI tip calculator in a single step. Does the class have prerequisites, or is it specifically targeted at people who want to learn on their own, but with a general guidance?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The assignment says you can use the console for input and output. That's far easier than a Swing GUI.
 
Daniel Sheppard
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its Intro to Business Programming. It has no prereqs...its the first step.
 
Saloon Keeper
Posts: 10705
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
TO THE MODERATOR - Op can and should use console IO for this project as this is simpler than digging in to swing. With that in mind I suggest moving this thread back to 'beginner'.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Carey Brown wrote:TO THE MODERATOR - Op can and should use console IO for this project as this is simpler than digging in to swing. With that in mind I suggest moving this thread back to 'beginner'.


It's in both forums. It can be removed from Swing should the OP decide to go that way (recommended).

Complete aside: what lame course excepts a Swing GUI after introducing "Hello world"?
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Daniel,

It is possible to do this without using a JFrame and reading the bill amount using JOptionPane can be done with about the same amount of code that it would take using Scanner.

Take a look at the documentation on JOptionPane, specifically showInputDialog() and then experiment with it. I should add, too, that although the documentation doesn't say it, you can (and in this case should) specify null for the parentComponent parameter.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic