Thread View: aus.computers.java
1 messages
1 total messages
Started by mrbafner
Sat, 03 Jul 1999 00:00
Maybe someon Can help???
Author: mrbafner
Date: Sat, 03 Jul 1999 00:00
Date: Sat, 03 Jul 1999 00:00
73 lines
3009 bytes
3009 bytes
Hi,
I am pretty new to java, and I know you probably think this is a stupid
question. Though I am trying to get input from on 3 different lines and add
them, then take away tax from the final figure.
Here is what I have written so far, can you help me please?
================================================
import java.io.*;
public class SalesTax1 {
final static double Tax_Rate = 0.3; // salestax percentage
public static void main (String[] args)
throws IOException
{
System.out.println ("SALES TAX CALCULATOR"); // create a text input
stream
BufferedReader stdin = new BufferedReader
(new InputStreamReader (System.in)); // this
allow people to input something, then the computer can work of these figures
String initString;
int initialPrice; // stores user input
int initialPrice1; // stores user input
int initialPrice2; // stores user input
double finalPrice; // stores salary minus tax
double tax; // stores payable tax
System.out.print ("Enter the Price: \n");
System.out.print ("Enter the Price: \n");
System.out.print ("Enter the Price: ");
initString = stdin.readLine();
initialPrice = Integer.parseInt (initString); // calculate
payable tax
initialPrice1 = Integer.parseInt (initString);
initialPrice2 = Integer.parseInt (initString);
if (initialPrice == (initialPrice + initialPrice1 + initialPrice2) )
{
tax = initialPrice / Tax_Rate ;
}
else
{
tax = initialPrice * Tax_Rate;
} // calculate netto income
finalPrice = initialPrice - tax; // Output
System.out.println();
System.out.println("Original Price : " + initialPrice );
System.out.println("Original Price : " + initialPrice1 );
System.out.println("Original Price : " + initialPrice2 );
System.out.println("Sales Tax (" + Tax_Rate + " %): " + tax );
System.out.println("--------------------------------");
System.out.println("New Price : " + finalPrice );
}
}
=================================================
any comments would be much appreciated thankyou
MrBafner
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads