Answer to Question #174813 in C++ for meng

Question #174813

UPrint is a T-Shirt printing company that charges different rates depending on how many T-shirts a customer would like to have printed and how many colors will be used. The rates are as follows.

 

1 color

1–99 shirts: RM18 per T-shirt

100–249 shirts: RM16 per T-shirt

250 or more shirts: RM15 per T-shirt

2 colors

1–99 shirts: RM19 per T-shirt

100–249 shirts: RM17 per T-shirt

250 or more shirts: RM16 per T-shirt

3 colors

1–99 shirts: RM20 per T-shirt

100–249 shirts: RM18 per T-shirt

250 or more shirts: RM17 per T-shirt

 

Write a program in which a user can enter the number of T-shirts they would like to be printed and with how many colors (1, 2, or 3). Calculate the cost based on the company’s rates and include UPrint sales and use tax of 6%. Print this total ringgit amount to the screen, formatted to two decimal places. Here is a demo of the program.



1
Expert's answer
2021-03-23T23:17:58-0400
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
	int colour = 0;
	double sum = 0;
	cout << "Enter how many colours you want will be used(1-3): ";
	cin >> colour;
	int shirt = 0;
	cout << "How many T-Shirts you want(0 - many): ";
	cin >> shirt;
	if (colour == 1)
	{
		if (shirt < 100)
		{
			sum = shirt * 18 * 1.06;
		}
		if (shirt >= 100 && shirt < 250)
		{
			sum = (18 * 99 + (shirt - 99) * 16) * 1.06;
		}
		if (shirt >= 250)
		{
			sum = (18 * 99 + 150 * 16 + (shirt - 249) * 15) * 1.06;
		}
	}
	if (colour == 2)
	{
		if (shirt < 100)
		{
			sum = shirt * 19 * 1.06;
		}
		if (shirt >= 100 && shirt < 250)
		{
			sum = (19 * 99 + (shirt - 99) * 17) * 1.06;
		}
		if (shirt >= 250)
		{
			sum = (19 * 99 + 150 * 17 + (shirt - 249) * 16) * 1.06;
		}
	}
	if (colour == 3)
	{
		if (shirt < 100)
		{
			sum = shirt * 20 * 1.06;
		}
		if (shirt >= 100 && shirt < 250)
		{
			sum = (20 * 99 + (shirt - 99) * 18) * 1.06;
		}
		if (shirt >= 250)
		{
			sum = (20 * 99 + 150 * 18 + (shirt - 249) * 17) * 1.06;
		}
	}
	cout << fixed << setprecision(2) << "Total cost of " << shirt << " T-Shirts with " << colour << " colours (+ taxes) is: " << sum << " RM." << endl;
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS