| Author |
Java program Swing
|
Jake Olofsson
Greenhorn
Joined: Feb 07, 2012
Posts: 3
|
|
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
Joined: May 03, 2008
Posts: 3221
|
|
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
|
luck, db
There are no new questions, but there may be new answers.
|
 |
Jake Olofsson
Greenhorn
Joined: Feb 07, 2012
Posts: 3
|
|
Yes it probably is JOptionPane, because that's what we used in the other program. Thanks...
|
 |
Randall Twede
Ranch Hand
Joined: Oct 21, 2000
Posts: 3905
|
|
|
just take it one step at a time. finding the mean should be the only real challenge
|
I never took notes in college. That's how I got a 4.0 the first 2 years, and a 3.5 the second two years.
|
 |
Jake Olofsson
Greenhorn
Joined: Feb 07, 2012
Posts: 3
|
|
|
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
Joined: Oct 31, 2011
Posts: 110
|
|
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.
|
My Blog - Java SE Quick Downloads
|
 |
 |
|
|
subject: Java program Swing
|
|
|