You are on page 1of 3

Maria Arias

Chapter 4 Homework

11. A-1 Appliances needs a program that allows the store clerks to enter the number of dishwashers in
stock at the beginning of the month, the number purchased during the month, and the number sold
during the month. The program should calculate and display the number of dishwashers in stock at
the end of the month.

Input Process Output


beginStock Calculate & display endStock
purchased endStock = beginStock + purchased - sold
sold

#include <iostream>
using namespace std;
int main()
{
int beginStock, purchased, sold, endStock;

cout << "Please enter the number of dishwashers at the beginning of the month: ";
cin >> beginStock;
cout << "Thank you\n \nNow enter the number of dishwashers that were purchased
this month: ";
cin >> purchased;
cout << "Thank you\n \nNow enter the number of dishwashers that were sold this
month: ";
cin >> sold;
endStock = beginStock + purchased - sold;
cout << "Thank you\n \nThere are currently " << endStock << " dishwashers in
stock.\n";

system("pause");
return 0;
}
12. A concert hall has three seating categories: Orchestra, Main floor, and Balcony. Orchestra seats
are $25. Main floor seats are $30, and Balcony seats are $15. The manager wants a program that
allows him to enter the number of tickets sold in each seating category. The program should
calculate and display the amount of revenue generated by each seating category, as well as the total
revenue.

Input Process Output


orchestraTicket totalRevenueOrchestra = orchestraTicket * totalRevenueOrchestra
mainFloorTicket ORCHESTRA totalRevenueMainFloor
balconyTicket totalRevenueMainFloor = mainFloorTicket * totalRevenueBalcony
ORCHESTRA=25 MAINFLOOR totalRevenue
MAINFLOOR=3 totalRevenueBalcony = balconyTicket * BALCONY
0 totalRevenue = totalRevenueOrchestra +
BALCONY=15 totalRevenueMainFloor + totalRevenueBalcony

#include <iostream>
using namespace std;
int main()
{
int orchestraTicket, mainFloorTicket, balconyTicket;
const int ORCHESTRA = 25, MAINFLOOR = 30, BALCONY = 15;
int totalRevenueOrchestra, totalRevenueMainFloor, totalRevenueBalcony,
totalRevenue;

cout << "Hello! Please enter the number of orchestra tickets sold: ";
cin >> orchestraTicket;
cout << "Thank you\n \nNow enter the number of main floor tickets sold: ";
cin >> mainFloorTicket;
cout << "Thank you\n \nNow enter the number of balcony tickets sold: ";
cin >> balconyTicket;

totalRevenueOrchestra = orchestraTicket * ORCHESTRA;


totalRevenueMainFloor = mainFloorTicket * MAINFLOOR;
totalRevenueBalcony = balconyTicket * BALCONY;
totalRevenue = totalRevenueOrchestra + totalRevenueMainFloor +
totalRevenueBalcony;

cout << "Thank you\n \nOrchestra seating revenue: $" << totalRevenueOrchestra <<
"\nMain Floor seating revenue: $" << totalRevenueMainFloor << "\nBalcony seating revenue:
$" << totalRevenueBalcony << "\n \nTotal Revenue: $" << totalRevenue << endl;

system("pause");
return 0;
}
13. The manager of Mama Calari’s Pizza Palace wants a program that calculates and displays the
number of slices of pizza into which a circular pizza can be divided. The manager will enter the radius
of the pizza. For this exercise, use the number 14.13 as the area of a pizza slice, and use 3.14 as the
value of pi.

Input Process Output


radius Area = PI * radius^2 area

#include <iostream>
using namespace std;
int main()
{
double radius, area;
const double PI = 3.14;

cout << "Enter the radius of the pizza: ";


cin >> radius;
area = PI * pow(radius, 2);
cout << "The area of the pizza is " << area << endl;
system("pause");
return 0;
}

You might also like