Question

There are three floors in a hospital. Each floor has five wards. Each ward can contain...

There are three floors in a hospital. Each floor has five wards. Each ward can contain a maximum of 20 patients. This is a twodimensional array, storing an integer value representing the number of patients in a ward. Once the numbers of patients in each ward have been input into an array, determine and print the following: Which ward on which floor has the most patients? Which floor has the highest number of patients? Include a check to ensure the number of patients entered does not exceed 20.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <bits/stdc++.h>
using namespace std;
int main()
{
int i,j,k;
int a[3][5];
for(i=0;i<3;i++)
{
for(j=0;j<5;j++)
{
cout<<"Enter the number of patient's in floor "<<i+1<<" and ward "<<j+1<<" : ";
cin>>a[i][j];
while(a[i][j]>20)
{
cout<<"Patients cant be more than 20\nPlease enter again";
cin>>a[i][j];
}
}
}

int maxi=-1;
pair<int, int > p;
for(i=0;i<3;i++)
{
for(j=0;j<5;j++)
{
if(maxi<a[i][j]){
maxi=a[i][j];
p.first=i+1;
p.second=j+1;
}
}
}
cout<<"Floor "<<p.first<<" ward "<<p.second<<" has most patients"<<endl;
int floor=-1;
maxi=-1;
for(i=0;i<3;i++)
{
int sum=0;
for(j=0;j<5;j++)
{
sum+=a[i][j];
}
if(maxi<sum)
{
maxi=sum;
floor=i+1;
}
}
cout<<"Floor "<<floor<<" has the highest number of patients";

}

Add a comment
Know the answer?
Add Answer to:
There are three floors in a hospital. Each floor has five wards. Each ward can contain...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A block of flats has 27 floors with ten flats on each floor. Each flat has...

    A block of flats has 27 floors with ten flats on each floor. Each flat has six rooms. Find and print the following: The total area for each flat (print this value and the floor and flat numbers). The total area for each floor (to be stored in a one-dimensional array and printed at the end of processing). Print the contents of this array with the respective floor numbers. The total area for the building. The area of each room...

  • There are 10 floors in a hotel (numbered from 0 to 9). On each floor there...

    There are 10 floors in a hotel (numbered from 0 to 9). On each floor there are 26 rooms, each marked with a capital letter of the English alphabet (from "A" to "Z"). Your task is to compute which room was booked most frequently, based on a list of room reservations. The list of reservations consists of N three-character strings. The first character of the string is "+" or "−", which describes whether the room was booked or freed. The...

  • write a complete Java program with comments in main and in each method. Data: The input data for this program is given as two columns of numbers. All data will be entered from a fle named input.t...

    write a complete Java program with comments in main and in each method. Data: The input data for this program is given as two columns of numbers. All data will be entered from a fle named input.txt and all output will go to the screen Assume there will not be more than 100 7 23.56 16 88.12 10 75.1 Design a Java class with a main method that does the following 1) Reads the data into two arrays of doubles,...

  • Question 5: Conceptual Design (25 marks) The Felicity Stillwell Hospital (FSH) is a small hospital located...

    Question 5: Conceptual Design (25 marks) The Felicity Stillwell Hospital (FSH) is a small hospital located in the southern suburbs of Perth, specialising in the health care of elderly patients. As the first phase of a complete information systems redevelopment, you have been contracted to design the database that will support its data and processing requirements. Depending on how well you perform, you may be asked to implement the design at some later time. Detailed information on the data recorded,...

  • Positive and negative: Return these four results using C++ reference parameter Write a function, named sums(),...

    Positive and negative: Return these four results using C++ reference parameter Write a function, named sums(), that has two input parameters; an array of floats; and an integer, n, which is the number of values stored in the array. Compute the sum of the positive values in the array and the sum of the negative values. Also count the number of positives and negative numbers in each category. Write a main program that reads no more than 10 real numbers...

  • Java Switch Case Make From Pseudocode

    The following pseudo-code describes a menu-driven algorithm:loopask the user to input one of the characters a, b, c, d, e, q read in a character from the keyboardif the character is'a' output your name and your tutor's name (hard-coded) 'b' input 3 double numbers x, y, z and output the largestand the smallest of the three numbers'c' input 2 integer numbers m and n, and display all thenumbers between m and n (both inclusive) with five numbers per line (note...

  • Write a C program with a filename netID_intarray.c that has 2 arrays. One is a two-dimensional...

    Write a C program with a filename netID_intarray.c that has 2 arrays. One is a two-dimensional array of strings which contains 5 words, each word can be a max of 20 characters long. The list of strings should be static in your code. The second integer array is populated by prompting the user for 10 integers to be stored in the array. Here is the simple output: $ ./run Number Work Enter integer 1 for the array: 45 Enter integer...

  • The files must be called Proper coding conventions required the first letter of the class start...

    The files must be called Proper coding conventions required the first letter of the class start with a capital letter and the first letter of each additional word start with a capital letter. Only submit the .java file needed to make the program run. Do not submit the .class file or any other file. 5% Style Components Include properly formatted prologue, comments, indenting, and other style elements as shown in Chapter 2 starting page 64 and Appendix 5 page 881-892....

  • CIST 2371 Introduction to Java Unit 03 Lab Due Date: ________ Part 1 – Using methods...

    CIST 2371 Introduction to Java Unit 03 Lab Due Date: ________ Part 1 – Using methods Create a folder called Unit03 and put all your source files in this folder. Write a program named Unit03Prog1.java. This program will contain a main() method and a method called printChars() that has the following header: public static void printChars(char c1, char c2) The printChars() method will print out on the console all the characters between c1 and c2 inclusive. It will print 10...

  • C++ Program - Arrays- Include the following header files in your program:     string, iomanip, iostream Suggestion:...

    C++ Program - Arrays- Include the following header files in your program:     string, iomanip, iostream Suggestion: code steps 1 thru 4 then test then add requirement 5, then test, then add 6, then test etc. Add comments to display assignment //step 1., //step 2. etc. This program is to have no programer created functions. Just do everything in main and make sure you comment each step. Create a program which has: 1. The following arrays created:                 a. an array...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT