# java integers

• April 20th, 2010, 08:15 AM
timeline
java integers
hi again to all i need to do this exercises
i am not good at java but i have to deliver them so
there they are , can someone help me
thanks

EXERCISE 1
Write a java program that receives the keyboard two integers and
shows the result of dividing the first of the latter.
; If the values are not corresponding to integers appear appropriate message,
after handling the exception NumberFormatException.
; If the division can not be done because the denominator is equal to zero, be
Handling ArithemticException and appears suitable message.

EXERCISE 2

write a program java, using headings File, FileReader and FileWriter to do
the following:
1. Examine whether the file «src.txt» is the current directory. If there should be
terminates the execution of using the exception FileNotFoundException.
2. Copies the contents of the file src.txt dest.txt, adding a blank line after
each line src.txt plus replacing all spaces with the @ character.
3. Finally, it displays the size in bytes of the file and src.txt dest.txt, both before the opening as
after closing the file.
• April 20th, 2010, 11:59 AM
lucasantos
Re: java integers
Hy, this is the my solution for Exercise 1.
If u don't specify 2 input, in console u find "I need 2 input as parameters";
If the input aren't integer, the message will be "Inputs have to be integer";
If the second input is 0, the message will be "Is not possible divide by zero"
Code :

```public class exe1 { public static void main(String[] args) { if (args.length<2) { System.err.println("I need 2 input as parameters"); }else{ int a; int b; try{ // I'm tring to convert the first input a = Integer.parseInt(args[0]); // I'm tring to convert the second input b = Integer.parseInt(args[1]);   System.out.println("The result is: " + (a/b));   }catch(NumberFormatException e){ System.err.println("Inputs have to be integer"); }catch(ArithmeticException e){ System.err.println("Is not possible divide by zero"); }   } }   }```
• April 21st, 2010, 05:31 PM
timeline
Re: java integers
thx for the help :)
• April 22nd, 2010, 10:33 AM
helloworld922
Re: java integers
:( we don't do other people's assignments for them on this forum. Timeline, please show us what effort you've made to solve the problem and we will help you figure out what's not working correctly.
• April 23rd, 2010, 02:54 AM
timeline
Re: java integers
its ok you r right thanx anyway