Home arrow static arrow Java Programming [Archive] - I need Help...
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - I need Help...
This topic has 5 replies on 1 page.

Posts:2
Registered: 7/30/04
I need Help...  
Jul 30, 2004 10:45 AM



 
I'm not sure if this is the right thread for this but i've been having a mare trying to answer these questions, for my assignment, I know this sounds alot, but i've struggled on this for so long, tutors are no help so i really need your help? does anyone know the answers: (Java Basics)

1) Design and write a program which prompts the user to input two intergers, subtracts the first from the second and displays the result?

2) design & write a program which prompts the user to enter two intergers: if 2 numbers are equal it multiplies them anddisplays a message in the following format: 'The Square of 5 is 25' (assuming the value of the number was 5 ), otherwise it multiplies them and displays a message in the following format: 'The product of 5 and 6 is 30' (assuming the two numbers were 5 and 6 respectively).

3) Design and write a program which promts a user to enter a seqence of 10 integers which are stummed and the total dispalyed. If the user inputs a negative number it is ignored i.e the running total is not updated. The user will not be allowed to input more than 10 numbers even if some of them are negative?

Each answer needs, PDL Design, A Java Implementation and Test plan plan showing test cases and sample test data.

cheers,

sarah Thomas
heartandsoul_1@hotmail.com
 

Posts:24,036
Registered: 2/3/03
Re: I need Help...  
Jul 30, 2004 10:51 AM (reply 1 of 5)



 
I'm not sure if this is the right thread for this but
i've been having a mare trying to answer these
questions, for my assignment, I know this sounds
alot, but i've struggled on this for so long, tutors
are no help so i really need your help? does anyone
know the answers: (Java Basics)

Yes.

Now, if you would like some help, please ask a [url=http://www.catb.org/~esr/faqs/smart-questions.html]specific question[/url] (like what you've tried that isn't working) rather than posting the whole assignment.
 

Posts:105
Registered: 6/8/04
Re: I need Help...  
Jul 30, 2004 11:04 AM (reply 2 of 5)



 
[url=http://java.sun.com/j2se/1.4.2/docs/api/]The Java API's[/url] are an invaluable resource when coding in Java. As you gain experience, you'll get better at finding the classes you need on your own, but I'll point you in the right directions for now:

[url=http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html]System[/url] is good for doing stuff in the console--the most basic input and output, specifically. However, the standard input is hard to deal with alone; try getting a [url=http://java.sun.com/j2se/1.4.2/docs/api/java/io/BufferedReader.html]BufferedReader[/url] to wrap around it (you'll need one more class between them; see if you can find it).

Also, when dealing with integers, the [url=http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Integer.html]Integer[/url] class has some good utility methods you might want to look into...

Sorry I'm being vague, and you may have some trouble finding the specific methods and classes I'm trying to hint at, but the better you get at finding what you need from the API's, the easier Java will be for you.

Good luck!
 

Posts:69
Registered: 4/23/01
Re: I need Help...  
Jul 30, 2004 3:16 PM (reply 3 of 5)



 
How about this, I help you do the first one and you can do the rest.
Asking for help is justified but try to make a sincere attempt initally if you wish to learn.

1)
import java.io.*; public class Example {    int sum = 0;        public Example(){	try {	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));	String str = "";	     for (int i =1; i <3; i++) {	           System.out.print(" Enter number " + i + " >  ");	            str = in.readLine();		            sum += Integer.parseInt(str);			    }	System.out.println(" The sum is  : " + sum );					} catch (IOException e) {             e.printStackTrace();	}    }     public static void main(String[] args) {        Example ex = new Example ();    }}


Cheers:
 

Posts:2
Registered: 7/30/04
Re: I need Help...  
Jul 31, 2004 5:31 AM (reply 4 of 5)



 
oh! thank you so much, sure i understand what your saying? i've just been going round and round in circles with this, it's been driving me crazy...

sarah
 

Posts:11,200
Registered: 7/22/99
Re: I need Help...  
Jul 31, 2004 7:14 AM (reply 5 of 5)



 
What have you done so far? What is stopping you from continuing? Without knowing the answers to those two questions it is not possible to give useful help.

What's PDL?
 
This topic has 5 replies on 1 page.