• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java operator

 
Kalpesh Jadhav
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello I have assignment , could you please help me to solve this?

Write a program where in user enters 2 operand and a operator feed the same in file and read the file and display the Output result with all the operations in the end.
 
Henry Wong
author
Marshal
Pie
Posts: 21446
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kalpesh Jadhav wrote:Hello I have assignment , could you please help me to solve this?

Write a program where in user enters 2 operand and a operator feed the same in file and read the file and display the Output result with all the operations in the end.



Yeah, standard homework problem. It's actually a fun one in my opinion.

Anyway, tell us what you did so far, what issues your are running into (in as much details as possible), and we will give you some hints to help resolve those issues.

Henry
 
Campbell Ritchie
Sheriff
Pie
Posts: 49865
71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch

Are you using Java7?
 
Kalpesh Jadhav
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I have take that all value in one file.
After that I have read that file one by one and do the operation on it.
I written code to write enter data to the file but I am not able to enter continuously the data in file .its just accepting one value only /
I have written this much code ,

 
Campbell Ritchie
Sheriff
Pie
Posts: 49865
71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have added code tags, which usualy improves the look of your code, unfortunately is this case it highlights the inconsistent indentation. Are you supposed to have a loop in there? It is difficult to see, but I don’t think you do. That may be why you are only reading one value.
You shouldn’t need to flush System.out(). You have forgotten to close your reader.
By the way: don’t use tabs for indenting.
 
Kalpesh Jadhav
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written this much by this code I am able to accept the values till user don't say "n".
And those value get updated in file also ,
Now my next task is todo operation. How to do this?

 
Winston Gutkowski
Bartender
Pie
Posts: 10509
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kalpesh Jadhav wrote:I have written this much by this code I am able to accept the values till user don't say "n".
And those value get updated in file also ,
Now my next task is todo operation. How to do this?

Did you read Campbell's post? Because you are still flushing System.out and you still haven't closed your reader (and, probably more importantly, your writer).
Also, please UseCodeTags properly.

You also need to explain what you mean by "todo operation" (at least for me).

Winston

 
Campbell Ritchie
Sheriff
Pie
Posts: 49865
71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are mistaken that your loop (if you actually have a loop) continues until the user enters “n”. It actually runs as long as he enters something starting with y (not Y). I don’t think while(true) ... break; is good style. Have a look at this thread.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic