Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
    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
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Carey Brown
  • Frits Walraven

figuring out how I could have done my final java program.

Posts: 3
  • Mark post as helpful
  • send pies
  • Report post to moderator
hi,  I did not do well in the final but I feel that it was too hard with the limited time. anyway, I'm here to figure out how I could have done it.

import java.util.Scanner;
public class Tax {
   public static void main(String args[]) {
       Scanner input=new Scanner(;
   System.out.println("Please enter the amount of your taxable income");
    double income=input.nextDouble();
      double tax;
      double rate;
       double total;
       double t;
       System.out.printf("your taxable income is=%.2f",income);
 rate= tax/100;
  total= income*rate;
System.out.printf("\n your total income after taxes is=%.2f",t);
this is the code, his explanation was for example if the input was 45000 then somehow in the program it would be like 45000=20000+20000+5000 then it would find the total after taxes for each then add them together. like 20000(0)+20000(0.1)+5000(0.2)= something. so my question is how I could make the program divide the input like that. one of my theories was to put the question in to make the person input his income over and over till the total reaches the limit but that would go against his explanation.
Thank you
Posts: 15519
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Report post to moderator
Duplicate thread. Locking this one. Please continue discussion in the original thread:
It is difficult to free fools from the chains they revere - Voltaire. tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
    Bookmark Topic Watch Topic
  • New Topic