Answer to Question #171278 in C++ for Rose

Question #171278

2. Write a program to determine the price for a portrait sitting. The price is determined by subjects in portraits, background chosen and sitting appointment day.

The fee schedule is shown below. 

Fancy background and sitting appointment cost an extra 10 percent more than the base price.

 

Subjects in Portrait

Base Price

1

$100

2

$130

3

$150

4

$160

5 or more

$165

Sample Output1:

Enter the number of subjects in the portrait: 1

Do you want a fancy background (y/n)? y

Do you want an appointment date (y/n)? y

The price is: $120

 

Sample Output2:

Enter the number of subjects in the portrait: 6

Do you want a fancy background (y/n)? y

Do you want an appointment date (y/n)? n

The price is: $181.5


1
Expert's answer
2021-03-12T14:54:42-0500
 #include <iostream>

int main() {
	int base_price[] = { 100, 130, 150, 160, 165 };
	int num;
	double price;
	std::cout << "Enter the number of subjects in the portrait: ";
	std::cin >> num;
	if (num > 5)
		num = 5;
	price = base_price[num - 1];
	
	char ch;
	std::cout << "Do you want a fancy background (y/n)? ";
	std::cin >> ch;
	if (ch == 'y')
		price += base_price[num - 1] * 0.1;
	
	std::cout << "Do you want an appointment date (y/n)? ";
	std::cin >> ch;
	if (ch == 'y')
		price += base_price[num - 1] * 0.1;

	std::cout << "The price is: $" << price << std::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