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

[JAVA] **only one question Write a complete Java program called CalcTotalPrice.

ID: 665202 • Letter: #

Question

[JAVA] **only one question

Write a complete Java program called CalcTotalPrice. The program must include five methods: getSaleTotal, getSalePrice, getSaleWeight, calcTax, and calcShipping. getSaleTotal takes no input parameters and returns a double, which is the sale total, and which it computes by calling the other four methods. getSalePrice returns a double, which it gets from the user at the command line. getSaleWeight returns a double, which it gets from the user at the command line. calcTax takes a double as a parameters (the sale price) and returns the tax amount as a double (use 6% as a fixed tax rate). calcShipping takes a double as a parameter (the sale weight) and returns the shipping amount as a double (calculate shipping as $10 if weight is less than 10 and $20 if weight is 10 or greater). getSaleTotal should print the sale price amount, tax amount, shipping amount, and sale total amount to the command line.

Explanation / Answer

import java.util.Scanner; /** * * @author Kramer1 */ public class CalcTotalPrice { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here } public static double getSaleTotal(){ Scanner in = new Scanner(System.in); double price = getSalePrice(in); System.out.println(price); double tax = calcTax(.06); System.out.println(tax); double shipping = calcShipping(in.nextDouble()); System.out.println(shipping); double saleTotal = ((price)*tax)+price+shipping; System.out.println(saleTotal); return saleTotal; } public static double getSalePrice(Scanner in){ double salePrice = in.nextDouble(); return salePrice; } public static double getSaleWeight(Scanner in){ double saleWeight = in.nextDouble(); return saleWeight; } public static double calcTax(double salePrice){ double salesTax = .06; return salesTax; } public static double calcShipping(double saleWeight){ double amountShipping = 0; if (saleWeight < 10){ amountShipping = 10.; }else if(saleWeight > 10){ amountShipping = 20.; } return amountShipping; } }
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