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
  • 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,...

  • 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...

  • Write a C++ computer program that simulates the action of an elevator that is out of...

    Write a C++ computer program that simulates the action of an elevator that is out of order. After simulating the motion of the elevator, your program will display a bar chart that shows the number of times the elevator stays on each floor of a twenty-five-story building. When you arrive on the scene to begin studying the elevator, it is on the twelfth floor of the twenty-five-story building. Every five minutes the elevator either moves up one floor or down...

  • 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...

  • 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...

  • Using C++ create a lotto program Lottery Design a program that simulates a lottery. Requirements:  The program...

    Using C++ create a lotto program Lottery Design a program that simulates a lottery. Requirements:  The program should have an array of 5 integers named lottery and should generate a random number in the range of 1 through 99 for each element of the array. The user should enter five digits, which should be stored in an integer array named user. The program is to compare the corresponding elements in the two arrays and keep a count of the digits that...

  • Using basic c++ write 2 separate codes for this assignment. Program #1 Write a program that...

    Using basic c++ write 2 separate codes for this assignment. Program #1 Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions. • void getScore() should ask the user for a test score, store it in the reference parameter variable, and validate it. This function should be called by the main once for each of the five scores to be entered. •...

  • 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
ADVERTISEMENT