• Post Reply Bookmark Topic Watch Topic
  • New Topic

do while  RSS feed

 
Amrit Kaur
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is the question:
1) Set deposit to 1000
2) print heading (“YEAR    DEPOSIT     INTEREST      TOTAL”)
3) Set year to 0
4) WHILE Deposit <= 2000 DO
5) Add 1 to year
6) Set Interest to 10% of Deposit, i.e. Deposit * 0.1
7) Set Total to Deposit + Interest
8) print ( Year, Deposit, ,Interest, Total)
9)   Set Deposit to Total [the new deposit for the next year]
10) END WHILE
11) Print (“The total first exceeds $2000 at the end of year”, year)
12) print (“ The amount is”, Deposit)
13) stop
write a program in java for the above. this is what i have so far,and it doesnt give me an output that is required. can i be helped and correct me where i have made mistakes please? Thank you in advance,here is my code:
 
Tim Cooke
Marshal
Posts: 4051
239
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly, for the purposes of copyright can you please cite the source of the question?

Can you elaborate on "doesnt give me an output that is required"? What are you expecting? What do you get?
 
Amrit Kaur
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
his is what i have so far,and it doesnt give me an output that is required i mean that my program does not run,i have errors interest and deposit is not declared but when i declare them the errors are yet the same,no change. Just says errors it does not run the program at all. can i be helped and correct me where i have made mistakes please?
 
Swastik Dey
Rancher
Posts: 1815
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the code compile?  I have never seen this kind of a syntax before.
 
Amrit Kaur
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swastik Dey wrote:Does the code compile?  I have never seen this kind of a syntax before.

it has errors,i jus need some help to understand and fix my code please? thank you
 
Amrit Kaur
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Cooke wrote:Firstly, for the purposes of copyright can you please cite the source of the question?

Can you elaborate on "doesnt give me an output that is required"? What are you expecting? What do you get?

i do not get any output i mean the code has errors, i declared interest and total yet i have errors,can i be helped with the code? please?
 
Swastik Dey
Rancher
Posts: 1815
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It has syntactical errors.  The system out statements should be like this



and



and you are probably missing declarations for variables interest and total.

 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amrit Kaur wrote:
it has errors,i jus need some help to understand and fix my code please? thank you


It would be a good idea to tell us (1) what errors are you getting, (2) what do you think those errors are, and (3) what have you tried to fix them.  Without knowing what your issues / thoughts are, it will be difficult in giving you hints in the right direction.

Henry
 
Amrit Kaur
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swastik Dey wrote:It has syntactical errors.  The system out statements should be like this



and



and you are probably missing declarations for variables interest and total.


Thank you that is what i was missing out. thank you so much
 
Swastik Dey
Rancher
Posts: 1815
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are welcome.  We are always happy to help you.
 
Amrit Kaur
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:
Amrit Kaur wrote:
it has errors,i jus need some help to understand and fix my code please? thank you


It would be a good idea to tell us (1) what errors are you getting, (2) what do you think those errors are, and (3) what have you tried to fix them.  Without knowing what your issues / thoughts are, it will be difficult in giving you hints in the right direction.

Henry

sorry for the inconvenience, i have been helped. Thank you so much.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!