Java Assignment Help.
#6

Quote:
Originally Posted by ColonelBurton
Посмотреть сообщение
so at the last line i have to change it to
Char ch = input.nextChar();

Still i need to figure out how to replace 2nd and 4th in num and replace it with integer d.
As well display the precedent and the letter that comes after ch before&after the number.
Yep, a char would work for that.

Incase its not too late yet, take a look at the Java API for Strings : http://docs.oracle.com/javase/6/docs...ng/String.html

The examples at the top already point into exactly the direction you need.
You cant actually replace the digits in the string without extra efforts, but you can cut out the parts you need from the number, and then recombine the string, inserting the d integer and the chars where you need them.
For that you should take a closer look at the example, the substring, and the length method. Im pretty sure this the expected solution, as other ways to do it are more complicated.

I dont like just giving the solutions and explaining them for assignments. Its much more helpful if you work it out yourself, with just having hints where to look


@RaZVaN ^ xD
This would be an alternative solution. Though I dont think they expect a solution like that for the assignment, as its more complicated, and rather focuses on math than on the java language (and it wouldnt work if the number wasnt 4 digits long without extra effort )
Reply


Messages In This Thread
Java Assignment Help. - by ColonelBurton - 01.11.2014, 16:35
Re: Java Assignment Help. - by Mauzen - 01.11.2014, 17:09
Re: Java Assignment Help. - by ColonelBurton - 01.11.2014, 19:15
Re: Java Assignment Help. - by IvanSb - 01.11.2014, 19:34
Re: Java Assignment Help. - by RaZVaN ^ xD - 02.11.2014, 00:28
Re: Java Assignment Help. - by Mauzen - 02.11.2014, 00:52
Re: Java Assignment Help. - by BroZeus - 02.11.2014, 08:07
Re: Java Assignment Help. - by Infinity - 02.11.2014, 08:17
Re: Java Assignment Help. - by BroZeus - 02.11.2014, 08:37
Re: Java Assignment Help. - by Infinity - 02.11.2014, 10:28

Forum Jump:


Users browsing this thread: 3 Guest(s)