Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • 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 ...
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Output format off?  RSS feed

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

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

My code:

Any help would be appreciated

Saloon Keeper
Posts: 5140
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.
ice is for people that are not already cool. Chill with this tiny ad:
Download Free Java APIs to Work with Office Files and PDF
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!