need the output to have the decimal points lined up for any test data I decide to use. How could I do that in this code?. (The computer language that I am using is c++) #include #include //Define constant for tax rate #define taxRate 0.0788 using namespace std; int main() { //Set the precision to two decimal places cout << setprecision(2) << fixed; const double EXT_MONITOR=159.99; const double DELL_KEYB=18.30; const double DELL_MOUSE=16.45; const double WIND_OS=199.99; const double PRINTER=599.89; int extMonitor,d_keyboards,d_mouse,wind_OS,printer; double costEMonitor,costDell_key,cost_d_mouse,costWindOs,costPrinter; double total=0,subtotal,tax; //Get the required inputs from the user cout<<"How many External Monitor s were ordered? "; cin>>extMonitor; cout<<"How many Dell keyboards players were ordered? "; cin>>d_keyboards; cout<<"How many Dell Mouse units were ordered? "; cin>>d_mouse; cout<<"How many Windows 10 OS were ordered? "; cin>>wind_OS; cout<<"How many Network Printers were ordered? "; cin>>printer; //Compute cost for external monitor costEMonitor=EXT_MONITOR*extMonitor; //Compute cost for dell mouse cost_d_mouse=DELL_MOUSE*d_mouse; //Compute cost for dell keyboard costDell_key=DELL_KEYB*d_keyboards; //Compute cost for windows OS costWindOs=WIND_OS*wind_OS; //Compute cost for printer costPrinter=PRINTER*printer; //Compute cost for sub total subtotal=costEMonitor+costDell_key+cost_d_mouse+costPrinter+costWindOs; //Print the output cout<<"\nQTY Description Unit Price Total Price"<

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter3: Assignment, Formatting, And Interactive Input
Section3.4: Program Input Using Cin
Problem 8E
icon
Related questions
Question

I need the output to have the decimal points lined up for any test data I decide to use. How could I do that in this code?. (The computer language that I am using is c++)

#include <iostream>
#include <iomanip>
//Define constant for tax rate
#define taxRate 0.0788
using namespace std;
int main()
{
//Set the precision to two decimal places
cout << setprecision(2) << fixed;
const double EXT_MONITOR=159.99;
const double DELL_KEYB=18.30;
const double DELL_MOUSE=16.45;
const double WIND_OS=199.99;
const double PRINTER=599.89;
int extMonitor,d_keyboards,d_mouse,wind_OS,printer;
double costEMonitor,costDell_key,cost_d_mouse,costWindOs,costPrinter;
double total=0,subtotal,tax;
//Get the required inputs from the user
cout<<"How many External Monitor s were ordered? ";
cin>>extMonitor;
cout<<"How many Dell keyboards players were ordered? ";
cin>>d_keyboards;
cout<<"How many Dell Mouse units were ordered? ";
cin>>d_mouse;
cout<<"How many Windows 10 OS were ordered? ";
cin>>wind_OS;
cout<<"How many Network Printers were ordered? ";
cin>>printer;
//Compute cost for external monitor
costEMonitor=EXT_MONITOR*extMonitor;
//Compute cost for dell mouse
cost_d_mouse=DELL_MOUSE*d_mouse;
//Compute cost for dell keyboard
costDell_key=DELL_KEYB*d_keyboards;
//Compute cost for windows OS
costWindOs=WIND_OS*wind_OS;
//Compute cost for printer
costPrinter=PRINTER*printer;
//Compute cost for sub total
subtotal=costEMonitor+costDell_key+cost_d_mouse+costPrinter+costWindOs;
//Print the output
cout<<"\nQTY Description Unit Price Total Price"<<endl;
cout<<extMonitor<<setw(15)<<" EXTERNAL MONITOR "<<setw(6)<<EXT_MONITOR<<" "<<setw(6)<<costEMonitor<<endl;
cout<<d_keyboards<<setw(15)<<" DELL KEYBOARD "<<setw(6)<<DELL_KEYB<< " "<<setw(6)<<costDell_key<<endl;
cout<<d_mouse<<setw(15)<<" DELL MOUSE "<<setw(6)<<DELL_MOUSE<< " "<<setw(6)<<cost_d_mouse<<endl;
cout<<wind_OS<<setw(15)<<" WINDOWS OS "<<setw(6)<<WIND_OS<< " "<<setw(6)<<costWindOs<<endl;
cout<<printer<<setw(15)<<" NETWORK PRINTER "<<setw(6)<<PRINTER<< " "<<setw(6)<<costPrinter<<endl;
cout<<"\nSUBTOTAL "<<subtotal<<endl;
//Compute tax
tax=subtotal*taxRate;
//Compute total
total=subtotal+tax;
cout<<"TAX "<<tax<<endl;
cout<<"TOTAL "<<total<<endl;

return 0;
}

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning