C++ program that calculate the price of pages and envelopes
Posted by Samath
Last Updated: November 05, 2014

The treasurer of CHOPS wants a C++ program that will help her to prepare a customer’s bill. She will enter the number of typed envelopes and the number of typed pages, as well as the charge per typed envelope and the charge per typed page. The program should calculate and display the amount due for the envelopes, the amount due for the pages, and the total amount due.

 

Here is the Solution to the problem above: 

#include <iostream>
#include <iomanip>
using namespace std;
int main(int argc, char *argv[])
{
	int num_typed_envel;
	int num_typed_pages;
	float charge_typed_envel;
	float charge_typed_pages;
	float envelopes_amount;
	float page_amount;
	float total_amount;
	
	cout<<"Enter the amount of typed envelopes: ";
	cin>>num_typed_envel;
	
	cout<<"Enter the amount of typed pages: ";
	cin>>num_typed_pages;
	
	cout<<"Enter the amount charge per typed envelope: ";
	cin>>charge_typed_envel;
	
	cout<<"Enter the amount charge per typed page: ";
	cin>>charge_typed_pages;
	
	envelopes_amount = num_typed_envel * charge_typed_envel;
	page_amount = num_typed_pages * charge_typed_pages;
	total_amount = envelopes_amount + page_amount;
	
	cout<<endl<<"Envelopes: $"<<setprecision(2) << fixed <<envelopes_amount<<endl;
	cout<<"Pages: $"<<setprecision(2) << fixed <<page_amount<<endl;
	cout<<"Total: $"<<setprecision(2) << fixed <<total_amount<<endl;
	
	return 0;
}
Related Content