Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
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
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);
double income=input.nextDouble();
double tax;
double rate;
double total;
double t;
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