Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

Output format off?  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm trying to get my program to output these specifications:


Please enter first zipcode:  17551
Please enter second zipcode:  90210
MILLERSVILLE, PA 17551 is 2331.91 miles from BEVERLY HILLS, CA 90210


This is what I get:

Please enter first zipcode: 00705
Please enter second zipcode :10458
0
28
0is691.8896753827131from28



My code:



Any help would be appreciated


 
Bartender
Posts: 5776
56
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On lines 112 and 113 you are printing the indexes not the contents at those indexes. On line 115 you are using printf() incorrectly. printf() takes as its first argument a format string, followed by zero or more parameters to provide the values for the specified formats. You are passing in a composite string that is already formatted and not correctly.
 
Police line, do not cross. Well, this tiny ad can go through:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!