Question

This is JAVA. Must write a short description of this program, usually a sentence or two...

This is JAVA. Must write a short description of this program, usually a sentence or two will be sufficient. All the classes, methods and data fields should be clearly documented (commented).

Write a program that will ask the user to enter the amount of a purchase. The program should then compute the state and county sales tax. Assume the state sales tax is 4 percent and the county sales tax is 2 percent. The program should display the amount of the purchase, the state sales tax, the county sales tax, the total sales tax, and the total of the sale (which is the sum of the amount of purchase plus the total sales tax).

Hint: Use the value 0.02 to represent 2 percent, and 0.04 to represent 4 percent.

Example Run

Enter the purchase amount: 30.8
Purchase amount: $30.8
State tax: $1.232
County tax: $0.616
Total tax: $1.8479999999999999
Total cost: $32.648

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE

import java.util.Scanner;

/**

* Java code to calculate the total purchase cost of a product which includes state sales tax of 4% and county sales tax of 2%.

*/

public class Main {

/*

* main method which asks the user for the purchase cost of an item and finds the total cost including the taxes.

*/

public static void main(String[] args) {

double purchaseAmount; // field to store the user input for the purchase price of the item

Scanner sc = new Scanner(System.in);

System.out.println("Enter the purchase amount: ");

purchaseAmount = sc.nextDouble();

double stateTax = 0.04 * purchaseAmount; // calculate the state tax

double countyTax = 0.02 * purchaseAmount; // calculate the county tax

System.out.println("Purchase amount: $" + purchaseAmount);

System.out.println("State tax: $" + stateTax);

System.out.println("County tax: $" + countyTax);

System.out.println("Total tax: $" + (stateTax + countyTax));

System.out.println("Total cost: $" + (purchaseAmount + stateTax + countyTax));

}

}

Add a comment
Know the answer?
Add Answer to:
This is JAVA. Must write a short description of this program, usually a sentence or two...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Java, write a program that will ask the user to enter the amount of a...

    In Java, write a program that will ask the user to enter the amount of a purchase. The program should then compute the state and county sales tax. Assume the state sales tax is 4 percent and the county sales tax is 2 percent. The program should display the amount of the purchase, the state sales tax, the county sales tax, the total sales tax, and the total of the sale (which is the sum of the amount of purchase...

  • Write a program that will compute the total sales tax on a $95 purchase. Assume the...

    Write a program that will compute the total sales tax on a $95 purchase. Assume the state sales tax is 4 percent and the county sales tax is 2 percent ... and then display the amounts for the total sales tax, state sales tax, and county sales tax. the pseudo code is: since the tax rates do not vary, we will declare them as constants: const double STATE_SALES_TAX_RATE = 0.04 //copy initialization const double CNTY_SALES_TAX_RATE(0.02) //direct initialization declare variable to...

  • Property Tax Program -Must use C programming I attempted this program but couldn't figure what I...

    Property Tax Program -Must use C programming I attempted this program but couldn't figure what I did wrong ;( Property Tax Program Complete the following program: A retail company must file a monthly sales tax report listing the total sales for the month and the amount of state and county sales tax collected. The state sales tax rate is (4 percent and the county sales tax rate is 2 percent. Write a program that asks the user to enter the...

  • C++ chapter 2 programming challenge #3 Write a program that will compute the total sales tax...

    C++ chapter 2 programming challenge #3 Write a program that will compute the total sales tax on a $95 purchase. Assume the state sales tax is 4 percent, and the county sales tax is 2 percent.

  • java; programing language Write a program to calculate the price of a purchase. It should ask...

    java; programing language Write a program to calculate the price of a purchase. It should ask the user to enter the name of the item bought (like sweater, apple, …), number of items bought (4, 5 lbs,…), price per item ($40.50, $1.99 per pound,…), and the sales tax rate (8.35% for example). It should calculate the subtotal (price*number of items), sales tax (subtotal*sales tax), and total price (subtotal+ sales tax). It should print all the information in a receipt form

  • Q2.     Write a program that will compute the total sales tax on a $45 purchase. Assume...

    Q2.     Write a program that will compute the total sales tax on a $45 purchase. Assume that the state sales tax is 4% and county sales tax is 2%. Declare a variable called price , of datatype double Ask the user to enter a price and the user inputs in the purchase price. Use setprecision(2) like Q1. in C++

  • Your instructor would like you to write a program in Java which would ask for the clerk to enter ...

    Your instructor would like you to write a program in Java which would ask for the clerk to enter the total amount of the customer’s order. The program will then calculate a seven percent (7%) sales tax. Commission is computed based on the following: order amount id="mce_marker" - $200 commission is 2%, order amount $201 - $400 commission is 3%, order amount $401 - $600 commission is 4%, order amount > $600 commission is 5%, The program will display the...

  • Can you solve this proble by using C# application? C# is one of programming languages supported...

    Can you solve this proble by using C# application? C# is one of programming languages supported by Visual Studio 2015. It combines the features of Java and C ++ and is suitbale for rapid application development. A retail company must file a monthly sales tax report listing the total sales for the month, and the amount of state and county sales tax collected. The state sales tax rate is 4% and the county sales tax rate is 2%. Create an...

  • Java coding help! Write a program to simulate a bank which includes the following. Include a...

    Java coding help! Write a program to simulate a bank which includes the following. Include a commented header section at the top of each class file which includes your name, and a brief description of the class and program. Create the following classes: Bank Customer Account At a minimum include the following data fields for each class: o Bank Routing number Customer First name Last name Account Account number Balance Minimum balance Overdraft fee At a minimum write the following...

  • .Need code for my java class !! Write a simple java program that uses loops. You...

    .Need code for my java class !! Write a simple java program that uses loops. You may use ‘WHILE’ or ‘FOR’ or ‘DO-WHILE’ – you decide. The program should use a loop to compute the semester average for up to 5 students. In the loop the user will ask for a student name and their 3 test scores and add them up and divide the total by 3 giving the semester average. You will print out the student name and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT