Chapter 2 – Q #13: Circuit Board Price – Tony Gaddis – Starting Out With C++

Chapter 2 – Q #13:  Circuit Board Price – Tony Gaddis – Starting Out With C++





Problem: -

An electronics company sells circuit boards at a 40 percent pro t. Write a program that will calculate the selling price of a circuit board that costs $12.67. Display the result on the screen.

Solution: -

#include <iostream>

using namespace std;

int main()

{

      const float circuit_price = 12.67;

      float profit = (40 / 100.0) * circuit_price;

      float selling_price = 0.0;

      selling_price = circuit_price + profit;

      cout << "Selling Price OF Circuit Board is " << selling_price;

      return 0;

}

This is the solution of this question




OUTPUT OF THIS QUESTION




Explanation of this Solution


  1. I declared a float data type constant and initialize given value.
  2. I declared another variable named profit and calculate profit.
  3. I declared a float data type variable named selling price.
  4. Then, calculate price and store in total selling price variable.
  5. In last, display output of distance on the screen.
  6. Return 0 to the main function.

Also, I attach CPP file of this problem. You can download this file

Click Here to Download This File




Thanks!  

Post a Comment

0 Comments