fork download
  1. //Charlotte Davies-Kiernan CS1A Chapter 2 P.83 #13
  2. //
  3. /******************************************************************************
  4.  *
  5.  * Compute Circuit Board Price
  6.  * ____________________________________________________________________________
  7.  * This program calculates the selling price of a circuit board that is
  8.  * sold at a percentage of profit
  9.  *
  10.  * Computaion is based on the formula:
  11.  * selling price = cost + (cost * profit rate)
  12.  * ____________________________________________________________________________
  13.  * INPUT
  14.  * cost : Constant for cost of the circuit board
  15.  * profitRate : Constant for profit percentage
  16.  * OUTPUT
  17.  * sellingPrice : Price of the circuit board including the profit percentage
  18.  *****************************************************************************/
  19. #include <iostream>
  20. #include <iomanip>
  21. using namespace std;
  22. int main()
  23. {
  24. float cost; //INPUT - constant for cost of the circuit board
  25. float profitRate; //INPUT - constant for profit percentage
  26. float sellingPrice; //OUTPUT -circuit board price including profit percentage
  27. //
  28. // Initialize Program Variables
  29. cost = 12.67;
  30. profitRate = 0.40;
  31. //
  32. // Compute Selling Price
  33. sellingPrice = cost + (cost * profitRate);
  34. //
  35. // Output Result
  36. cout << std::fixed << std::setprecision(2); //format ouput to 2 decimal places
  37. cout << "Selling price of the circuit board: $" << sellingPrice << endl;
  38.  
  39. return 0;
  40. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
Selling price of the circuit board: $17.74