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

I need help starting this program. 15. Create a program that displays a table co

ID: 3685713 • Letter: I

Question

I need help starting this program. 15. Create a program that displays a table consisting of ten rows and four columns. The first column should display prices from $5 to $50 in increments of $5. The second and subsequent columns should display the discounted prices, using discount rates of 10%, 15%, and 20%, respectively. If necessary, create a new project named Intermediate15 Project, and save it in the Cpp8Chap08 folder. Enter the C++ instructions into a source file named Intermediate15.cpp. Also enter appropriate comments and any additional instructions required by the compiler. Save and then run the program. Thank you

Explanation / Answer

#include<iostream>
#include <iomanip>
using namespace std;

int main(){
  
   //creating a table of 10 rows and 4 columns
   double table[10][4];
  
   //putting price in first column
   double price = 5;
   for(int i=0; i<10; i++){
       table[i][0] = price;
       price = price + 5; // with increment of 5
   }
  
   // filling 2nd, 3rd, and 4th column
   double discount = 0.10; // 10%
   for(int i=1; i<4; i++){
      
       for(int j=0; j<10; j++){
           table[j][i] = table[j][0] - table[j][0]*discount; // discounted price
       }
      
       //increment siscount by 5% (0.05)
       discount = discount + 0.05;
   }
  
   //printing
   for(int i=0; i<10; i++){
       for(int j=0; j<4; j++){
           cout<<setw(6)<<table[i][j]<<" ";
       }
       cout<<endl;
      
   }
  
   return 0;
}

/*

Output:

5 4.5 4.25 4
10 9 8.5 8
15 13.5 12.75 12
20 18 17 16
25 22.5 21.25 20
30 27 25.5 24
35 31.5 29.75 28
40 36 34 32
45 40.5 38.25 36
50 45 42.5 40

*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote