• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help Explain  RSS feed

 
Tthuta Soe
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I finished my assignment 1 ok. but I was sick for like last 2 session of my course, so I miss some array and things. I can't do properly my assignment 2. Can you guys explain things and crack me some codes ? please explain me line by line or give me a link where I can read about this.
Screen-Shot-2016-02-04-at-7.49.20-PM.png
[Thumbnail for Screen-Shot-2016-02-04-at-7.49.20-PM.png]
Screen-Shot-2016-02-04-at-7.49.16-PM.png
[Thumbnail for Screen-Shot-2016-02-04-at-7.49.16-PM.png]
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And what have you done so far? Why do you think you need to know about arrays? If you have been ill, have you contacted your teacher for help? That may be a valid reason for additional help.
 
J. Kevin Robbins
Bartender
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have working code for question 3 of assignment 1? Let's start there. Post that code (please use code tags) and we'll talk about how you would go about modifying it to meet the requirements of assignment 2.
 
salvin francis
Bartender
Posts: 1649
37
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tthuta Soe wrote: .. I was sick for like last 2 session of my course, so I miss some array and things...

Oh that's bad mate. Here's how I can help out, Instead of helping in your assignment, can we first know the topics that you skipped so that we can give you good tutorial links on the same ?

Here's a good one on Arrays :
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html


 
salvin francis
Bartender
Posts: 1649
37
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a simple code structure to help you out. Hopefully, you would be able to fill in the gaps
 
Tthuta Soe
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This is one
 
Tthuta Soe
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This is two
 
Tthuta Soe
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is three but not correct. It's as far as I reached
 
Dave Tolls
Ranch Foreman
Posts: 3056
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tthuta Soe wrote: This is three but not correct. It's as far as I reached


And what is the issue with it?
What does it do, and what should it do?
 
Tthuta Soe
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's a question above ! My Assignments
 
Dave Tolls
Ranch Foreman
Posts: 3056
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but what does your code fail to do that is required by that assignment?

This is your problem, remember, and you are asking people to help you, so it's generally a good idea to make it as easy as possible for them. It helps us and, as a result, helps you.
 
Tthuta Soe
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

question 1
To read a valid date.

Question 2.
Use a while loop to keep reading an integer from the keyboard. The loop will stop when the user enter an (any) negative number.
When the loop stops, you need to print the sum, average, lowest and highest numbers.

Question 3.
Read a String from the keyboard. The String represents a phone number. The phone number can contains letters:
A, B, C, a, b, c --> 1
D, E, F, d, e, f --> 2

The program is to convert the String to a phone number and display it.
 
Tthuta Soe
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't start the assignment 2 yet
 
Knute Snortum
Sheriff
Posts: 4270
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some notes on your first program:

* Package names are lowercase.
* Class names start with an uppercase letter.
* Don't write

write:

* This code:

...is probably wrong. && has a higher precedence than ||, so this evaluates like:

What you probably want is

* The following is wrong:

This says, "If the year is equal to the year divided by 4...". What you want is, "If the year is evenly divisible by 4..." To do this, use the modulo operator (%).

This says, "If the remainder after dividing by 4 is zero..."
 
Dave Tolls
Ranch Foreman
Posts: 3056
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tthuta Soe wrote:Hi,
...


Does your code work, though?

This is as important as what it is supposed to do.
What does it currently do?
Why is that incorrect?

It helps a lot to narrow down what problem you are having, otherwise we have to look through the whole code (and possibly compile and execute it) in order to find out what it is that you are having problems with.
Many of us don't have all that much time to expend on this, so the more effort you expend presenting your problem then the more likely you are to actually get responses to your issue.
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:. . .
* The following is wrong:

This says, "If the year is equal to the year divided by 4...". What you want is, "If the year is evenly divisible by 4..." To do this, use the modulo operator (%).

This says, "If the remainder after dividing by 4 is zero..."
You have the same problem with precedences there; you would need a second pair of () in that expression.

I think all these ifs are confusing and error‑prone. I suggest you can work out a daysInMonth variable much more neatly with a switch statement.
 
Tthuta Soe
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1 and 2 is working but 3 is not
 
Knute Snortum
Sheriff
Posts: 4270
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Saying "it doesn't work" doesn't tell us enough. What did you except? What happened instead? Did you get an error? What's the stack trace?
 
Tthuta Soe
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In question 3 if input is go adg1234 the out put gotta show 123-1234. or input is ad4j123 the out put should be 124-4123. something like that it will only read change the alphabet to numbers and read the numbers still as the numbers.
It won't execute if the number is longer or shorter than 7 words. It won't execute if you put other signs.and the hyphen will be included in after the third number.My program is working on the alphabet part but number parts is not working.
and I don't know how to put the hyphen in between. that's what's happening.
 
Knute Snortum
Sheriff
Posts: 4270
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ask yourself this: is GetNum() supposed to return something or print something? Some other things:

* Start variable and method names with a lowercase letter.
* Is Digits a good argument name? How many digits will it contain? Will it contain only digits?
* When you find yourself doing something like this:

...it probably makes sense to lowercase the whole string first.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!