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 ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

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

 
Greenhorn
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.in);
   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);
for(tax=0;income>=0&&income<=1000000;tax+=10){
 rate= tax/100;
  total= income*rate;
  t=income-total;
System.out.printf("\n your total income after taxes is=%.2f",t);
if(t<=0){
break;
}}
}}
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
 
Sheriff
Posts: 15519
263
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: https://coderanch.com/t/730475/java/figuring-final-java-program
 
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
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic