Re: I have a crisis
- From: "Oliver Wong" <owong@xxxxxxxxxxxxxx>
- Date: Wed, 14 Dec 2005 23:03:46 GMT
"JavaClueless" <u16672@uwe> wrote in message news:58d4c98a440c8@xxxxxx
>I am a freshman in college and I totally gotleftbehind in this Intro to
>Java
> class I'm taking. I have to hand in 7 assignments by the end of today.
> These
> are the first two assignments:
>
[snip, but will be addressed later]
>
> I have to do this to pass. Can anyone help me.
> Thank You!
I'm reminded of a quotation from Monique's father.
> "The assignment requires you to write two separate programs and thus
> consistes of two parts. The first part is to write a program that reads
> two
> numbers, let's say num1 and num2, each time using
> JOptionPane.showInputDialog,
> Then use, for instance,
>
> int value = Integer.parseInt(num1)
> to convert each number to an int. Then add them and print the results.
Do you know how the syntax of the Java language? This assignment almost
telling you exactly what it is you're supposed to type in. There's almost
not "thinking" or problem solving involved here; it's just memorization of
the rules of writing a legal Java program.
>
> The second part is to write a program that reads a 4-digit int, for
> instance,
> 3612, call it number. The program should separate the first two digits
> from
> the last two, and then add them. Thus in our example the program would
> assign
> 36 to a variable, let's say firstOne, and then assign 12 to a second
> variable,
> let's say secondOne. Finally, it would add the sum of firstOne and
> secondOne
> (here, 36 + 12, or 48) and assign it to a third variable, let's say sum.
>
> The output of your program should show the 4-digit integer read, the
> integer
> formed from the first two digits, the integer formed from the last two and
> then their sum. Hint: Use the %(mod) and /(intger division).
The hint gives one approach, but I'd probably use string manipulation
functions rather than modding and dividing. Choose whichever approach is
clearer to you.
> Use JOptionPane.showInputDialog to read your data and assign the input to
> the
> string number. Then use
> int value = Integer.parseInt(number)
> to convert number to an int.
Good luck.
- Oliver
.
- References:
- I have a crisis
- From: JavaClueless
- I have a crisis
- Prev by Date: Re: Username String suggestion
- Next by Date: Re: Username String suggestion
- Previous by thread: Re: I have a crisis
- Next by thread: Re: I have a crisis
- Index(es):
Relevant Pages
|