Saturday, October 20, 2012

java



To makes a profit a local store marks up the prices of its items by 25%. Write a Java program that declares the following variables:
 1. a double variable named percent_markedup
 2. a double variable named original_price
 3. a double variable named sales_tax_rate


 In your program be sure to assign a value to each of the variables 1-3 above. Use initialization for 1 and 2 and assignment for 3.

 Using the information from above, the program should then output:
 1. the original price of the item
 2. the marked-up percentage of the item (original price times percent of markup)
 3. the storeâ€?s selling price of the item
 4. the sales tax rate
 5. the sales tax
 6. the final price of the item (the final price of the item is the selling price plus the sales tax)


PROGRAM


public class FinalPrice{
 private static double percent_markedup= 25;
 private static double original_price = 100;
 private static double sales_tax_rate = 2;

 public void calculatePrice(){
 double storeSalPrice = original_price*percent_markedup/100;
 double tempSalPrice = original_price+storeSalPrice;
 double tempTaxPrice = tempSalPrice*sales_tax_rate/100;
 double taxSalPrice = tempSalPrice+tempTaxPrice;
 double finalPrice = tempSalPrice+tempTaxPrice;
 System.out.println("The original price="+original_price);
 System.out.println("The markedup percentage="+percent_markedup);
 System.out.println("The store Selling price="+tempSalPrice);
 System.out.println("The sales tax rate="+ sales_tax_rate);
 System.out.println("The sales tax price="+ tempTaxPrice);
 System.out.println("The final Price="+ finalPrice);
 }
 public static void main(String args[]){
 FinalPrice finalPrice = new FinalPrice();
 finalPrice.calculatePrice();
 }
 }

No comments:

Post a Comment