• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java program Swing  RSS feed

 
Jake Olofsson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, i'm learning java, but i don't understand a program that i'm supposed to do. And my teacher is not very willing to help!(I'm studying over the Internet) This is what it says:

"Make a program that reads in 3 positive numbers(if a negative number is entered, then no more input should be possible).

Then write out how many numbers that is bigger then 100, how many that is lower then 100 and how many that is exactly 100. Also write out how many values that has been entered.

Also display the mean value for the numbers over 100, and the mean value for the numbers below 100."

This is our second program that we are supposed to do. I did the first program without problems, but now i'm totally lost. How should i do? We are supposed to be working with swing. Should i use a scanner? Loop, If-statements?

Thanks.

 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Jake, and welcome to the Ranch! If you're supposed to be using Swing, you'll probably want to use a JOptionPane.

This tutorial may help: Getting the User's Input from a Dialog
 
Jake Olofsson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl Burke wrote:Hello Jake, and welcome to the Ranch! If you're supposed to be using Swing, you'll probably want to use a JOptionPane.

This tutorial may help: Getting the User's Input from a Dialog


Yes it probably is JOptionPane, because that's what we used in the other program. Thanks...
 
Randall Twede
Ranch Hand
Posts: 4589
6
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just take it one step at a time. finding the mean should be the only real challenge
 
Jake Olofsson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, the teacher has changed. It is not 3 positive numbers, but whatever amout of positive numbers that the user wants to put in. Not that it helps me. I'm totally lost, any more ideas what to read to understand this?
 
Nam Ha Minh
Ranch Hand
Posts: 512
Eclipse IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jake Olofsson wrote:Ok, the teacher has changed. It is not 3 positive numbers, but whatever amout of positive numbers that the user wants to put in. Not that it helps me. I'm totally lost, any more ideas what to read to understand this?


Use a loop to get input numbers from JOptionPane's input dialog method (as suggested by the guys above), until the input number is negative. Declare the variables that need to be calculated (3 ones). Then use if-else, comparator operators, variable assignments... to complete the requirement.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!