• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java operator

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 23956
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79467
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79467
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79467
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I am going to test your electrical conductivity with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic