Skip to Main Content

Java User Groups

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Can some one help me convert python code to java

Gayathri VenugopalAug 30 2018 — edited Aug 30 2018

Basically, this program takes the minimum, maximum and interval of all the stars and prints the asterisks accordingly. I have written the python code as:

  1. print("This program prints out lines of stars\n\n")
  2. minimum=int(input("What is the minimum number of stars?"))
  3. maximum=int(input("What is the maximum number of stars?"))
  4. interval=int(input("What is the interval?"))
  5. print("\n")
  6. for i in range(minimum,maximum+1,interval):
  7.    for j in range(i):
  8.    print("*",end='')
  9. print(" (%d stars)"%i)

Sample Run-

  1. This program prints outlines of stars.
  2. What is the minimum number of stars? 3
  3. What is the maximum number of stars? 15
  4. What is the interval? 4
  5. *** (3 stars)
  6. ******* (7 stars)
  7. *********** (11 stars)
  8. *************** (15 stars)
Comments
Post Details
Added on Aug 30 2018
1 comment
259 views