• 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

Data Manipulation

 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am doing a data manipulation as below:

Requirement 1:
• Aspect ratios can range from 20 to 85 in increments of 5.
• Round to the nearest 5. Examples: >72.5 and < 77.5, round to 75. >77.5 and < 82.5, round to 80. Valid values include: 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85.
Requirement 2:
o Tire widths can range from 145 mm to 395 mm, in increments of 10 mm; e.g., 145, 155, 165, 175, … 395.
o Round to the nearest value ending in a 5. Examples: if >150 and <160, round to 155. If >220 and <230, round to 225.

For the Requirement 1 I am using the following function and it is working fine. But for the Requirement 2 this function is not working. I would appreciate if someone can help to write a function for the Requirement 2.

Here is the Function for Requirement 1 which is working perfectly. I want to implement a similar function for the requirement 2 for the incremental of 10 instead of 5.

 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What did you try for #2, and in exactly what manner is it "not working"?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If your code for Requirement 1 is working perfectly, then the code you posted cannot be the actual code. Or at least if it is the actual code, lines 7 to 9 of your posted code are redundant and could be removed.
 
Sam Saha
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried this way but I am not getting correct values(10 intervals).


 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, so you're not getting the correct values. What values ARE you getting? The more relevant details you provide, the more likely it is that somebody will be willing and able to help you.

ItDoesntWorkIsUseless(←click).
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your requirements are written incorrectly. What do you do for a tyre exactly 160mm wide? You need to check for ≤ and ≥ symbols.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic