• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Beginners D Group  RSS feed

 
Owen ball
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All . Thought I'd start the ball rolling somehow as it all seemed a bit quiet in there!

So, we have to build a Calculator, and a currency converter. There's plenty of examples we can steal, but I guess we should really start from scratch. Anyone any suggestions as to how we should preceed? I'm a complete novice at this, just like the rest of you!

Owen
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first thing you should do is sit down and write a complete set of requirements. What functions are going to be required for this calculator? What is the user going to interact with the application? How are you going to get the values for currency conversion? Be as detailed and specific as possible.

Then, once you know exactly what you need to do, you start breaking it into pieces. Chances are it will lead you to more questions about specific things (how do you read user input on the command line, how do you parse text like this 1+2*3...). Places like this forum, the API, and the Java Tutorial are good places to go to try to answer those questions.

Once you have an idea of what you need to do and how you might go about it, you start to code one thing at a time, make sure it works, then add it to the rest of the code. Before you know it you'll be done.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Owen ball wrote:Anyone any suggestions as to how we should preceed?

Well, as far as the currency converter is concerned:

1. Do NOT use floating-point numbers.
2. Familiarize yourself with the standards, probably the best known of which is ISO 4217. This isn't specifically for programming, but it may well point out a few things you were unaware of, and also help you to create test data.

Winston
 
Mohamed Sanaulla
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... and welcome to JavaRanch!
 
Owen ball
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the advice fellas, currently scribbling down some requirements etc as suggested!

Owen
 
Gary Deer
Greenhorn
Posts: 27
Android Clojure Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve Luke wrote:The first thing you should do is sit down and write a complete set of requirements. What functions are going to be required for this calculator?



Think OOP...what objects are going to be required?
What are their attributes?
How are they going to interact with each other?

Visualize those and then you can start writing some pseudo-code to make sure your design meets all the requirements.
Comment your pseudo-code so when you go back and start coding it with Java you will remember what you were trying to do and also it will make your code easier to read and edit later. (Also, I'm sure your instructor takes points off for not commenting code)

Then translate that into actual Java code.

My last word of advice write your test code first. There's no better way to make sure you understand the requirements than to ensure you can account for every use case.

This is especially true if you're writing a program that a user interacts with.

Example: Let's say you are told to write a program that asks a user to enter his or her age and then spits out how much longer they have to live based on an average life expectancy of 70 years.
So you fire up the old IDE write some code that asks for a number, stores it in a variable called "age", and prints out "your remaining years are " + (70-age)

So then you go to test your program and you accidentally hit enter without entering an age...program crashes. You go back and add code to default to "0". So you're testing it again and this time you accidentally hit "111" instead of "11" and your program tells you that you should have died in 1970. You then wonder what would happen if you enter a negative number. Of course the program gives you an answer without questioning how someone that hasn't been born yet is able to use a computer. Instead of editing the code every time there is a bug, you now try to account for every type of input and rewrite the code to handle it all.

So now you have to go back and add if statements and loops which in turn introduces more bugs to look out for. If only you would have had all these examples before you started writing your code you would have known to test for them.

My suggestion is to look at the ISO 4217 standard and create your test data now.

Good luck.


 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gary Deer wrote:
Steve Luke wrote:The first thing you should do is sit down and write a complete set of requirements. What functions are going to be required for this calculator?



Think OOP...what objects are going to be required?


Actually, I'd go with what Steve said. Assuming the "functions" he's referring to are not "Java methods" but rather are in the sense of application feature functionality, i.e., use cases, such as "has to be able to multiply two numbers", etc. Requirements before design.
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Verdegan wrote:
Gary Deer wrote:
Steve Luke wrote:The first thing you should do is sit down and write a complete set of requirements. What functions are going to be required for this calculator?



Think OOP...what objects are going to be required?


Actually, I'd go with what Steve said. Assuming the "functions" he's referring to are not "Java methods" but rather are in the sense of application feature functionality, i.e., use cases, such as "has to be able to multiply two numbers", etc. Requirements before design.


Exactly what I meant: I was think along the line of 'what mathematical functions like multiplication, division, etc... need to be included in the product.
 
Gary Deer
Greenhorn
Posts: 27
Android Clojure Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve Luke wrote:
Jeff Verdegan wrote:
Gary Deer wrote:
Steve Luke wrote:The first thing you should do is sit down and write a complete set of requirements. What functions are going to be required for this calculator?



Think OOP...what objects are going to be required?


Actually, I'd go with what Steve said. Assuming the "functions" he's referring to are not "Java methods" but rather are in the sense of application feature functionality, i.e., use cases, such as "has to be able to multiply two numbers", etc. Requirements before design.


Exactly what I meant: I was think along the line of 'what mathematical functions like multiplication, division, etc... need to be included in the product.


Ah I see. As someone who had to go through shock therapy to break from structural programming habits to OOP, I tend to overreact to anything that sounds like structural programming. To be fair though, if I could get what you said confused, then that means Owen could have gotten it confused too. Now we can be sure that he knows what you meant which is good even though I looked like a jerk there for a bit.

 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gary Deer wrote:... Now we can be sure that he knows what you meant which is good even though I looked like a jerk there for a bit.


Haha, I don't think you looked like a jerk. And I am glad that any confusion was removed. The use of 'functions' can be ambiguous when talking both math and programming.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve Luke wrote:
Gary Deer wrote:... Now we can be sure that he knows what you meant which is good even though I looked like a jerk there for a bit.


Haha, I don't think you looked like a jerk. And I am glad that any confusion was removed. The use of 'functions' can be ambiguous when talking both math and programming.


++ on all counts
 
Alanna Morgan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Guys
I am only finding this forum now so sorry for the delay in joining in.
What is the progress and have we any ideas yet as how the work is going to be split?
I am happy for anyone to suggest a part of the project to work on and combine it with the rest.

 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alanna Morgan wrote:Hey Guys
I am only finding this forum now so sorry for the delay in joining in.
What is the progress and have we any ideas yet as how the work is going to be split?
I am happy for anyone to suggest a part of the project to work on and combine it with the rest.



This isn't really a thread full of folks collaborating on a calculator. It was one guy asking some very broad questions and getting accordingly general answers.

As far as I know, this site isn't appropriate for that kind of collaboration. If you want to participate in the OP's project, you should probably send him a Private Message so that you two can discuss the project in a more appropriate venue.

And, for that matter, the OP states that he "has to" build this calculator, so it's probably a school assignment, so collaboration with random people on the web is probably not allowed, though you should of course clarify that with the OP.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Owen ball wrote:Anyone any suggestions as to how we should preceed?


So, You Need to Write a Program but Don't Know How to Start

I'm a complete novice at this, just like the rest of you!


Just to clarify: The people who post questions here are generally novices, but there are a lot of experienced folks here answering questions.
 
Alanna Morgan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry but I am in Owens group,
he posted this link up on our group fourm in order to discuss the project.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alanna Morgan wrote:Sorry but I am in Owens group,
he posted this link up on our group fourm in order to discuss the project.


Ah, I see.

You'll want to keep internal project discussions on your own forum, and use this site for specific questions about Java.
 
Owen ball
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My Fault!

Our Tutor suggested we communicate as a group for our project on this site, but it seems its not appropriate. thanks for all your suggestions though lads!

Owen
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!