|
||
| The Following User Says Thank You to helloworld922 For This Useful Post: | ||
ocmjt (11-03-2010) | ||
|
|||
|
I dont think I put it in the right spot? Still no answer comes up?
Java Code
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
final double LOWTAXRATE = 0.1;
final double MEDTAXRATE = 0.15;
final double HIGHTAXRATE = 0.33;
double sumOfTax=0;
System.out.println("Please input the income, type -1 to end");
double income = keyboard.nextDouble();
double tax=0;
while(income>=0) {
if(income<=15000)
tax=income*LOWTAXRATE;
else if(income>60000)
tax=8250+(income-60000)*HIGHTAXRATE;
else if(income<=60000&&income>15000)
tax=1500+(income-15000)*MEDTAXRATE;
}
sumOfTax = sumOfTax + tax;
System.out.printf("The tax is $%.2f ", tax);
System.out.printf("The total tax is $%.2f ", sumOfTax);
System.out.println("Please input the income, type -1 to end");
income = keyboard.nextDouble();
}
}
|
|
|||
|
I think I got it..thanks a lot for your help! Can you explain what you mean with newline characters?
and does this look right? Java Code
import java.util.Scanner;
public class IncomeTax {
/**
* This program calculates federal taxes on a list containing various incomes
* Author: Marco Tomasello
* Date: March 8, 2010
*/
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
final double LOWTAXRATE = 0.1;
final double MEDTAXRATE = 0.15;
final double HIGHTAXRATE = 0.33;
double sumOfTax=0;
System.out.println("Please input the income, type -1 to end");
double income = keyboard.nextDouble();
double tax=0;
while(income>=0) {
if(income<=15000)
tax=income*LOWTAXRATE;
else if(income>60000)
tax=8250+(income-60000)*HIGHTAXRATE;
else if(income<=60000&&income>15000)
tax=1500+(income-15000)*MEDTAXRATE;
sumOfTax = sumOfTax + tax;
System.out.printf("The tax is $%.2f ", tax);
System.out.println("Please input the income, type -1 to end");
income = keyboard.nextDouble();
}
System.out.printf("The total tax is $%.2f ", sumOfTax);
}
}
|
|
||||
|
Yeah, I guess that looks like what you want. Newline characters are what put lines of text on different lines. Ex:
Java Code
System.out.println("This has no new lines. These two sentences are on the same line.");
System.out.println("The new line character is \\n.\n These two sentences are on different lines.");
__________________
ASCII a question .. Get an ANSI Please surround your code with [highlight=Java]code goes here[/highlight]. |
| The Following User Says Thank You to helloworld922 For This Useful Post: | ||
ocmjt (11-03-2010) | ||
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Check difference between no. of stops, calculate cost | JavaStudent23 | Java Theory & Questions | 4 | 17-11-2009 07:29 AM |
| Calculate primes help | TommyFiz | What's Wrong With My Code? | 3 | 28-10-2009 03:41 AM |
| Simple java program to calculate wall covering of a room | parvez07 | What's Wrong With My Code? | 3 | 22-08-2009 08:31 PM |
|
100 most searched terms
Search Cloud
|
| 2 dimensional arraylist java 2d arraylist java actionlistener actionlistener in java addactionlistener addactionlistener java convert double to integer java double format java double to integer in java double to integer java drag en drop programmeren java eclipse shortcut keys exception in thread "awt-eventqueue-0" java.lang.outofmemoryerror: java heap space exception in thread "main" java.lang.nullpointerexception exception in thread "main" java.lang.outofmemoryerror: java heap space format double in java format double java get mouse position java java 2d arraylist java actionlistener java double format java double formatting java double to int java double to integer java format double java forum java forums java get mouse position java list to map java mouse position java programming forum java programming forums java programming practice problems java send keystrokes to another application java two dimensional arraylist java.io.ioexception: premature eof java.lang.classformaterror: truncated class file java.lang.outofmemoryerror: java heap space java.util.arraylist jbutton action jbutton actionlistener jtextarea font jtextfield font size jxl.read.biff.biffexception: unable to recognize ole stream programming mutators and generics smack api two dimensional arraylist two dimensional arraylist java unable to sendviapost to url what is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? |