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

// This program calculates profits and sales prices for a furniture company. pub

ID: 3791703 • Letter: #

Question

// This program calculates profits and sales prices for a furniture company.

public class Furniture
{
   public static void main(String args[])
   {
       String itemName = "TV Stand";
       double retailPrice = 325.00;
       double wholesalePrice = 200.00;
       double salePrice;
       double profit;
       double saleProfit;
      
       // Write your assignment statements here.

      
      
       System.out.println("Item Name: " + itemName);
       System.out.println("Retail Price: $" + retailPrice);
       System.out.println("Wholesale Price: $" + wholesalePrice);
       System.out.println("Profit: $" + profit);  
       System.out.println("Sale Price: $" + salePrice);
       System.out.println("Sale Profit: $" + saleProfit);
       System.exit(0);


       System.exit(0);
   }
}

1. design the logic that will use assignment statements to first calculate the profit, then calculate the sale price, and finally calculate the profit when the sale price is used. profit is defined aas the retail price minus the whole sale price. The sale price is 25 percent deducted from the retail price. The sale profit is define as the sale price minus the wholesale price. PErform the appropriate calculations as part of your assignment statements.

2. compile

3. execute

4. output should be:

item name: TV stand

retail price: $325.0

wholesale price: $200.0

profit: $125.0

sale price: $243.75

sale profit: $43.75

Explanation / Answer

The program can be written in following way. The best way to write the program is using functions to carry out individual calculation:

public class Furniture

{

public static void main(String args[])

{

String itemName = "TV Stand";

double retailPrice = 325.00;

double wholesalePrice = 200.00;

double profit=calculateProfit(retailPrice, wholesalePrice);

double salePrice=calculateSalePrice(retailPrice, 25.00);

double saleProfit=calculateSaleProfit(salePrice, wholesalePrice);

  

// Write your assignment statements here.

  

  

System.out.println("Item Name: " + itemName);

System.out.println("Retail Price: $" + retailPrice);

System.out.println("Wholesale Price: $" + wholesalePrice);

System.out.println("Profit: $" + profit);

System.out.println("Sale Price: $" + salePrice);

System.out.println("Sale Profit: $" + saleProfit);

System.exit(0);

System.exit(0);

}

  

public static double calculateSaleProfit(double salesPrice, double wholesalePrice)

{

   return salesPrice - wholesalePrice;

}

  

public static double calculateSalePrice(double retailPrice, double deductionPercentage)

{

   return retailPrice - (retailPrice*deductionPercentage/100);

}

  

public static double calculateProfit(double retailPrice, double wholesalePrice)

{

   return retailPrice - wholesalePrice;

}

  

}

Second option to write the program would be - Without Function:

public class Furniture

{

public static void main(String args[])

{

String itemName = "TV Stand";

double retailPrice = 325.00;

double wholesalePrice = 200.00;

double profit=retailPrice - wholesalePrice;

double salePrice=retailPrice - (retailPrice*25/100);

double saleProfit=salePrice - wholesalePrice;

  

System.out.println("Item Name: " + itemName);

System.out.println("Retail Price: $" + retailPrice);

System.out.println("Wholesale Price: $" + wholesalePrice);

System.out.println("Profit: $" + profit);

System.out.println("Sale Price: $" + salePrice);

System.out.println("Sale Profit: $" + saleProfit);

System.exit(0);

System.exit(0);

}

}

public class Furniture

{

public static void main(String args[])

{

String itemName = "TV Stand";

double retailPrice = 325.00;

double wholesalePrice = 200.00;

double profit=calculateProfit(retailPrice, wholesalePrice);

double salePrice=calculateSalePrice(retailPrice, 25.00);

double saleProfit=calculateSaleProfit(salePrice, wholesalePrice);

  

// Write your assignment statements here.

  

  

System.out.println("Item Name: " + itemName);

System.out.println("Retail Price: $" + retailPrice);

System.out.println("Wholesale Price: $" + wholesalePrice);

System.out.println("Profit: $" + profit);

System.out.println("Sale Price: $" + salePrice);

System.out.println("Sale Profit: $" + saleProfit);

System.exit(0);

System.exit(0);

}

  

public static double calculateSaleProfit(double salesPrice, double wholesalePrice)

{

   return salesPrice - wholesalePrice;

}

  

public static double calculateSalePrice(double retailPrice, double deductionPercentage)

{

   return retailPrice - (retailPrice*deductionPercentage/100);

}

  

public static double calculateProfit(double retailPrice, double wholesalePrice)

{

   return retailPrice - wholesalePrice;

}

  

}