Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

ARRIZ JOHN O.

VILLAFLOR BSCE 2B

1. The payroll manager at Holmes Supply Company wants a program that allows her
to enter the payroll amount for each of three stores: Robinsons Mall, Gasiano
Mall, and SM Mall. The program should calculate the total payroll and then
display the result on the screen. The program will use a counter to ensure that
the payroll manager enters exactly three payroll amounts. It will use an
accumulator to total the amounts.

#include <iostream>

int main() {

const int NUM_STORES = 3;

const char* storeNames[NUM_STORES] = {"Robinsons Mall", "Gasiano Mall", "SM Mall"};

double totalPayroll = 0;

for (int store = 0; store < NUM_STORES; ++store) {

std::cout << "Enter payroll amount for " << storeNames[store] << ": ";

double payrollAmount;

std::cin >> payrollAmount;

while (std::cin.fail()) {

std::cin.clear();

std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');

std::cout << "Invalid input. Please enter a numeric value: ";

std::cin >> payrollAmount;

totalPayroll += payrollAmount;

std::cout << "\nTotal Payroll for all stores: $" << totalPayroll << "\n";

return 0;

You might also like