Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

can anyone show me how can I do this program in Java Write a program that reads

ID: 671277 • Letter: C

Question

can anyone show me how can I do this program in Java

Write a program that reads in dollar amounts from a file called dollars.txt, calculates the taxes owed, and prints the result to the screen. This code can be completed in your main function. The class for this program must be called Problem2.To test your code, create a simple text file named dollars.txt and add the values as follows:

10.0

100.0

1000.0

2000.0

The city tax rate is 3%, the county rate is 4%, and the state rate is 1%. The state rate is not applicable unless the purchase is over $1,000.00

Explanation / Answer

package mani;
import java.io.*;

public class Problem2 {
public static void main(String[] args) {
try {
   double sTax=0;
BufferedReader in = new BufferedReader
(new FileReader("c:\dollars.txt"));
String str;
while ((str = in.readLine()) != null) {
System.out.println();
System.out.println("cost of the purchase: "+str);
double p=Double.parseDouble(str);
double cTax=p*0.03;
double ctTax=p*0.04;
if(p>1000){
sTax=p*0.03;
}
double total=p+cTax+ctTax+sTax;
System.out.println("City Tax: "+cTax+" Country Tax: "+ctTax+" State Tax: "+sTax);
sTax=0;
}

}
catch (IOException e) {
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote