Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
Type your program source Select your Operating System click compile and download your executable file!
This is the C/C++ Online Compiler.
In online compilers (.net) you can find and use online many compilers ( GCC, MINGW, GFORTRAN, JAVA, GPC, FREEBASIC) for the mainstream languages that exist, you can search THE LINUX MANUAL (DEV MAN) PAGES, the JAVA & WIN32 API'S. Also, i have gathered some material to get you started with programming.
Latest User Submitted Question!

Name: Mary Ann
Title:
  Can run have an error
Question:
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

int main()
{
     //declare variables
     const string gadgets[] = {"CD", "KEYBOARD", "PRINTER", "PEN DRIVE", "SPEAKER"};
     const double unitprice[] = {60.00, 130.00, 850.00, 65.00, 12.50};
     const double taxrate = 3.25;
     int quantity[] = {0, 0, 0, 0, 0};
     double subtotal = 0;
     double taxamount = 0;
     double total = 0;
     double sum;

     //prompt user for quantity of each item
     for (int i=0; i<5; i  )
     {
          cout << "How many pack of " << gadgets[i] << " were sold? ";
          cin >> quantity[i];
     }

     //display summary and calculate total
     cout<< left << setw(5) << "QTY" << setw(10) <<  "DETAILS" << setw(15) << "UNIT PRICE (RM)" << fixed << setw(15) << "TOTAL PRICE (RM)" << endl;
     cout << "------ ------------ ----------------------- ---------------------------" << endl;

     for (int i=0; i<5; i  )
     {
          sum = unitprice[i] * quantity[i];
          subtotal  = sum;
          cout<< left << setw(5) << quantity[i] << setw(10) <<  gadgets[i] << setw(15) << setprecision(2) << fixed << unitprice[i] << setw(15) << sum << endl;
      }

     cout << "---------------------------------------------------------------------- " << endl;
     //calculate tax amount and total
     taxamount = (subtotal * taxrate)/100;
     total = subtotal   taxamount;

     //display summary
     cout << left << setw(14) << "SUBTOTAL : RM" << setprecision(2) << fixed << subtotal << endl;
     cout << left << setw(14) << "TAX : RM" << setprecision(2) << fixed << taxamount << endl;
     cout << left << setw(14) << "TOTAL : RM" << setprecision(2) << fixed << total << endl;

     return 0;
}
Answers:

Embedded News