Write an application that accepts the unit weight of a bag of coffee in pounds and
the number of bags sold and displays the total price of the sale, computed as
total price = unitweight * number of units * INR 25;
total price with tax = total price + totalprice * INR 0.70,
where 25 is the cost per 200grams and 0.70 is the sales tax. Use data type of
float.
import java.util.*;
class App {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter the unit weight of a bag of coffee in pounds: ");
float unitweight = in.nextFloat();
System.out.print("Enter the number of units: ");
float numberUnits = in.nextFloat();
float totalprice = unitweight * numberUnits * 25;
float totalpricetax = (float) (totalprice + totalprice * 0.70);
System.out.printf("\nThe total price: %.2f\n", totalprice);
System.out.printf("The total price tax: %.2f\n", totalpricetax);
in.close();
}
}
Comments
Leave a comment