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
#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;
}
Comments
Leave a comment