• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Help Explain

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]
 
Marshal
Posts: 80760
487
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 2911
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2911
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


This is one
 
Tthuta Soe
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


This is two
 
Tthuta Soe
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is three but not correct. It's as far as I reached
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's a question above ! My Assignments
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I haven't start the assignment 2 yet
 
Sheriff
Posts: 7126
185
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 80760
487
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1 and 2 is working but 3 is not
 
Knute Snortum
Sheriff
Posts: 7126
185
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 7126
185
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic