Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6804957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:31:45+00:00 2026-05-26T19:31:45+00:00

This is mine code, not fully finished, and sorry for Polish language but it’s

  • 0

This is mine code, not fully finished, and sorry for Polish language but it’s easy to get it.
http://pastebin.com/QPmVaPFv
So, this is about vet, 4 variables are for price per visitor:
1. Big dog
2. Medium dog
3. Small dog
4.cat
After that next 4 variables are for numbers of visitor, same as before (big,medium,small,cat etc.)

Then text says:
every 5th big dog owner got 10% discount
every 3rd medium owner got 50% discount
every 4th cat owner got price at 1$ i.e

double zdpies=ldpies/5.;
double zspies=lspies/3.;
double zkot=ckot/4.;

This is that part with discounts

after that i made variables with calculations on discounted price

double cdpiespromo=cdpies/10.; Big dog
double cspiespromo=cspies/50.; medium dog
double ckotpromo=1; Cat

Then i made calculation for final price i.e for normal price without discount

— cena normalna: 21.6 x 51.0 = 1101.6000000000001

Process completed.

And i got that strange numbers, 51. is ok but 21.6 is wrong that must be 22 not 21.6. When i use “int” it says there is “loss of precision”, any ideas how to fix that ?

Here are last variables for calculating final price discounted and without discount.

double idp=ldpies-zdpies; this calculates numbers of visitors without discount
double idc=idp*cdpies; this calculates price number of visitor * normalpriceofbigdog.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:31:46+00:00Added an answer on May 26, 2026 at 7:31 pm

    There’s a great article on using float, double, BigDecimal etc for doing calculation here http://firstclassthoughts.co.uk/java/traps/java_double_traps.html

    Bottom line is that there is no perfect solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Got some code that is not mine and its producing this warning atm: iehtmlwin.cpp(264)
This is my first app, and actually isn't even fully mine but rather involves
A friend of mine sent me this code snippet to celebrate his new baby
This question is related to a previous question of mine That's my current code
I have the following code in a class of mine. The purpose of this
I have read a lot about this issue but mine still seems to be
I want to do something: http://astro.unl.edu/naap/hr/animations/hrExplorer.html This example is in Flash but I'm doing
You may refer to this post of mine SQL going nuts! does not accept
I guess this question of mine is pretty basic but since Ive never done
How come this line of code mine shows an error of var searchUser =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.