how do i write a program that a user can input 3 numbers (between 0 and 100), then the program will compare if the numbers are bigger are smaller than each other, and weather each number is smaller than 100 or greater than 0. required 2 class file in one file ( first class will take the input numbers and pass them into the second class to compare). Thanks alot.

Recommended Answers

All 7 Replies

With a text editor and a jdk.

commented: Excellent! +1

c'mon please help me

Scanner class for reading input from keyboard. Search the forum for examples or look the API.
Or, use the args[] and enter the values from the command prompt.

If statements to check if it is between 0 and 100 and print error message and return.

One class will have a method that takes as arguments those 3 numbers and execute the comparison.
The other class will read the numbers and call the method of the first class with those numbers as parameters.

c'mon please help me

The description seems pretty complete to me, so the only thing I can think that you're asking is for us to do it for you, which we won't.

Post the what you've tried and/or ask a specific question about a specific aspect of the assignment that is giving you problems.

thanks for your help, and by the way how do i call a method? can you give me an example? Thnka :D

If i use the args[] then i will only be able to enter 1 value, i need 3, and i don't know what "scanner" is, my teacher didn't teach me that yet so can you be more specific about this scanner thing? Thnaks

thanks for your help, and by the way how do i call a method? can you give me an example? Thnka :D

If i use the args[] then i will only be able to enter 1 value, i need 3, and i don't know what "scanner" is, my teacher didn't teach me that yet so can you be more specific about this scanner thing? Thnaks

You will be able to enter as many values as you want with args. It is an array:

public static void main(String [B][][/B] args)

Console:

> java YourMainClass 1 2 3 4 5

The args array will have length the number of arguments you enter. And its elements would be the values entered.

As for calling methods, your teacher wouldn't have given that assignment if he hadn't teach you that. Look at your book or notes.

And it is difficult to help without knowing what you know. If you don't know the Scanner class what has your teacher told you?

Maybe you should start by hard coding 3 values to the code and continue from there:

int a = 5;
int b = 6;
int c = 3;

// the rest of the code

my teacher didn't teach me that yet

I'm quite sure you don't need your teachers help to find your way to Google or your course notes (if you have any)
if you find Scanner to dificult, ain't nobody saying you can't use the JOptionPane class. you'll have an input screen for each value you have to enter (unless you write your code otherwise), so it might be easier for you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.